Class FeatureFlag

java.lang.Object
org.elasticsearch.common.util.FeatureFlag

public class FeatureFlag extends Object
A utility class for registering feature flags in Elasticsearch code.
Typical usage:
{
    public static final FeatureFlag XYZZY_FEATURE_FLAG = new FeatureFlag("xyzzy");
    // ...
    if (XYZZY_FEATURE_FLAG.isEnabled()) {
        addRestHandlers();
        registerSettings();
        // etc
    }
 }

The feature flag will be enabled automatically in all snapshot builds. The feature flag can be enabled in release builds by setting the system property "es.{name}_feature_flag_enabled" to true (e.g. -Des.xyzzy_feature_flag_enabled=true

  • Constructor Details

    • FeatureFlag

      public FeatureFlag(String name)
  • Method Details

    • legacyRegisteredFlag

      @Deprecated public static FeatureFlag legacyRegisteredFlag(String name)
      Deprecated.
      This method exists to register feature flags that use the old {name}_feature_flag_registered naming for their system property, instead of the preferred {name}_feature_flag_enabled name. It exists so that old style feature flag implementations can be converted to use this utility class without changing the name of their system property (which would affect consumers of the feature).
    • isEnabled

      public boolean isEnabled()
    • toString

      public String toString()
      Overrides:
      toString in class Object