Class FeatureRule

  • All Implemented Interfaces:
    Rule<java.util.Map<java.lang.String,​java.lang.Boolean>>

    public final class FeatureRule
    extends java.lang.Object
    implements Rule<java.util.Map<java.lang.String,​java.lang.Boolean>>
    A rule that matches feature flags defined in the rule context.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  FeatureRule.Features
      Known feature flags.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String id()
      The id for declaring the rule value
      static void setFeature​(RuleContext context, java.lang.String feature, boolean value)
      Set a feature.
      boolean test​(RuleContext context, java.util.Map<java.lang.String,​java.lang.Boolean> value)
      Test if the declared value matches the current environment.
      com.google.gson.reflect.TypeToken<java.util.Map<java.lang.String,​java.lang.Boolean>> type()
      Data type of the rule.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

    • Method Detail

      • setFeature

        public static void setFeature​(RuleContext context,
                                      java.lang.String feature,
                                      boolean value)
        Set a feature.
        Parameters:
        context - the rule context that will eventually be tested
        feature - a feature flag
        value - the value for the feature
        See Also:
        for a selection of known features
      • id

        public java.lang.String id()
        Description copied from interface: Rule
        The id for declaring the rule value
        Specified by:
        id in interface Rule<java.util.Map<java.lang.String,​java.lang.Boolean>>
        Returns:
        the rule ID
      • type

        public com.google.gson.reflect.TypeToken<java.util.Map<java.lang.String,​java.lang.Boolean>> type()
        Description copied from interface: Rule
        Data type of the rule.

        This type will be used to deserialize rule values from a launcher metadata file.

        Specified by:
        type in interface Rule<java.util.Map<java.lang.String,​java.lang.Boolean>>
        Returns:
        the rule data type
      • test

        public boolean test​(RuleContext context,
                            java.util.Map<java.lang.String,​java.lang.Boolean> value)
        Description copied from interface: Rule
        Test if the declared value matches the current environment.
        Specified by:
        test in interface Rule<java.util.Map<java.lang.String,​java.lang.Boolean>>
        Parameters:
        context - the context representing the current environment
        value - the rule value
        Returns:
        whether there is a match