Package org.togglz.core.activation
Class GradualActivationStrategy
java.lang.Object
org.togglz.core.activation.GradualActivationStrategy
- All Implemented Interfaces:
ActivationStrategy
Activation strategy that enables features for a given percentage of users. This strategy is typically used to implement
gradual rollouts. The implementation is based on a hashcode created from the name of the acting user which is calculated by
calculateHashCode(FeatureUser, Feature).-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intcalculateHashCode(FeatureUser user, Feature feature) getId()A unique id for this strategy.getName()A human readable name of the strategy.Returns the list of configuration parameter definitions for the strategy.booleanisActive(FeatureState state, FeatureUser user) This method is responsible to decide whether a feature is active or not.
-
Field Details
-
ID
- See Also:
-
PARAM_PERCENTAGE
- See Also:
-
-
Constructor Details
-
GradualActivationStrategy
public GradualActivationStrategy()
-
-
Method Details
-
getId
Description copied from interface:ActivationStrategyA unique id for this strategy. This id is used to persist the selected strategy in theStateRepository.- Specified by:
getIdin interfaceActivationStrategy
-
getName
Description copied from interface:ActivationStrategyA human readable name of the strategy. This name is used to in the admin console to represent the strategy.- Specified by:
getNamein interfaceActivationStrategy
-
isActive
Description copied from interface:ActivationStrategyThis 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.- Specified by:
isActivein interfaceActivationStrategy- Parameters:
state- The feature state which represents the current configuration of the feature. The implementation of the method typically usesFeatureState.getParameter(String)to access custom configuration parameter values.user- The user for which to decide whether the feature is active. May benullif the user could not be identified by theUserProvider.- Returns:
trueif the feature should be active, elsefalse
-
calculateHashCode
-
getParameters
Description copied from interface:ActivationStrategyReturns the list of configuration parameter definitions for the strategy. Parameters are typically built using a
ParameterBuilderclass but users can also create custom implementations of theParameterinterface.Example:
public Parameter[] getParameters() { return new Parameter[] { ParameterBuilder.create("country").label("Country Code").matching("[A-Z]+") }; }- Specified by:
getParametersin interfaceActivationStrategy- See Also:
-