Package org.togglz.core.repository
Class FeatureState
- java.lang.Object
-
- org.togglz.core.repository.FeatureState
-
- All Implemented Interfaces:
Serializable
public class FeatureState extends Object implements Serializable
This class represents the state of a feature that is persisted byStateRepositoryimplementations.- Author:
- Christian Kaltepoth
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FeatureState(Feature feature)This constructor creates a new feature state for the given feature.FeatureState(Feature feature, boolean enabled)This constructor creates a new feature state for the given feature.FeatureState(Feature feature, boolean enabled, List<String> users)Deprecated.This constructor will be removed soon.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description FeatureStateaddUser(String user)Deprecated.This method will be removed soon.FeatureStateaddUsers(Collection<String> users)Deprecated.This method will be removed soon.FeatureStatecopy()Creates a copy of this state objectstatic FeatureStatecopyOf(FeatureState featureState)Returns a copy of a featureState, ornullif the featureState isnull.FeatureStatedisable()Disable the featureFeatureStateenable()Enable the featureFeaturegetFeature()Returns the feature represented by this feature state.StringgetParameter(String name)Returns the value of the given parameter.Map<String,String>getParameterMap()Returns an unmodifiable map of parametersSet<String>getParameterNames()Returns a list of all parameter names stored in theFeatureStateinstance.StringgetStrategyId()Returns the ID of the selected activation strategy.List<String>getUsers()Deprecated.This method will be removed soon.booleanisEnabled()Whether this feature is enabled or not.FeatureStatesetEnabled(boolean enabled)Enables or disables the feature.FeatureStatesetParameter(String name, String value)Sets a new value for the given parameter.FeatureStatesetStrategyId(String strategyId)Sets the selected activation strategy ID
-
-
-
Constructor Detail
-
FeatureState
public FeatureState(Feature feature)
This constructor creates a new feature state for the given feature. The feature is initially disabled if this constructor is used.- Parameters:
feature- The feature that is represented by this state.
-
FeatureState
public FeatureState(Feature feature, boolean enabled)
This constructor creates a new feature state for the given feature.- Parameters:
feature- The feature that is represented by this state.enabled- boolean indicating whether this feature should be enabled or not.
-
FeatureState
@Deprecated public FeatureState(Feature feature, boolean enabled, List<String> users)
Deprecated.This constructor will be removed soon. You should useFeatureState(Feature, boolean)andsetParameter(String, String)instead.This constructor creates a new feature state for the given feature. Please not that using this constructor will automatically set strategyId to match theUsernameActivationStrategy.- Parameters:
feature- The feature that is represented by this state.enabled- boolean indicating whether this feature should be enabled or not.users- A list of users
-
-
Method Detail
-
copy
public FeatureState copy()
Creates a copy of this state object
-
getFeature
public Feature getFeature()
Returns the feature represented by this feature state.- Returns:
- The feature, never
null
-
isEnabled
public boolean isEnabled()
Whether this feature is enabled or not.
-
setEnabled
public FeatureState setEnabled(boolean enabled)
Enables or disables the feature.
-
enable
public FeatureState enable()
Enable the feature
-
disable
public FeatureState disable()
Disable the feature
-
getUsers
@Deprecated public List<String> getUsers()
Deprecated.This method will be removed soon. UsegetParameter(String)instead to read the corresponding strategy parameter.The list of users associated with the feature state.- Returns:
- The user list, never
null
-
addUser
@Deprecated public FeatureState addUser(String user)
Deprecated.This method will be removed soon. UsesetParameter(String, String)instead to modify the corresponding strategy parameter.Adds a single user to the list of users
-
addUsers
@Deprecated public FeatureState addUsers(Collection<String> users)
Deprecated.This method will be removed soon. UsesetParameter(String, String)instead to modify the corresponding strategy parameter.Adds a single user to the list of users
-
getStrategyId
public String getStrategyId()
Returns the ID of the selected activation strategy.
-
setStrategyId
public FeatureState setStrategyId(String strategyId)
Sets the selected activation strategy ID
-
getParameter
public String getParameter(String name)
Returns the value of the given parameter. May returnnull.
-
setParameter
public FeatureState setParameter(String name, String value)
Sets a new value for the given parameter.
-
getParameterNames
public Set<String> getParameterNames()
Returns a list of all parameter names stored in theFeatureStateinstance.
-
getParameterMap
public Map<String,String> getParameterMap()
Returns an unmodifiable map of parameters
-
copyOf
public static FeatureState copyOf(FeatureState featureState)
Returns a copy of a featureState, ornullif the featureState isnull.
-
-