Interface ActivationStrategy

All Known Implementing Classes:
AbstractPropertyDrivenActivationStrategy, AbstractTokenizedActivationStrategy, GradualActivationStrategy, ReleaseDateActivationStrategy, ScriptEngineActivationStrategy, ServerIpActivationStrategy, SystemPropertyActivationStrategy, UsernameActivationStrategy, UserRoleActivationStrategy

public interface ActivationStrategy
This interface represents a custom strategy for deciding whether a feature is active or not. Togglz ships with a few default implementations.
Author:
Christian Kaltepoth
  • Method Summary

    Modifier and Type
    Method
    Description
    A unique id for this strategy.
    A human readable name of the strategy.
    Returns the list of configuration parameter definitions for the strategy.
    boolean
    isActive(FeatureState featureState, FeatureUser user)
    This method is responsible to decide whether a feature is active or not.
  • Method Details

    • getId

      String getId()
      A unique id for this strategy. This id is used to persist the selected strategy in the StateRepository.
    • getName

      String getName()
      A human readable name of the strategy. This name is used to in the admin console to represent the strategy.
    • isActive

      boolean isActive(FeatureState featureState, FeatureUser user)
      This method is responsible to decide whether a feature is active or not. The implementation can use the custom configuration parameters of the strategy stored in the feature state and information from the currently acting user to find a decision.
      Parameters:
      featureState - The feature state which represents the current configuration of the feature. The implementation of the method typically uses FeatureState.getParameter(String) to access custom configuration parameter values.
      user - The user for which to decide whether the feature is active. May be null if the user could not be identified by the UserProvider.
      Returns:
      true if the feature should be active, else false
    • getParameters

      Parameter[] getParameters()

      Returns the list of configuration parameter definitions for the strategy. Parameters are typically built using a ParameterBuilder class but users can also create custom implementations of the Parameter interface.

      Example:

       public Parameter[] getParameters() {
           return new Parameter[] {
                   ParameterBuilder.create("country").label("Country Code").matching("[A-Z]+")
           };
       }
       
      See Also: