Class PropertyBasedStateRepository
- java.lang.Object
-
- org.togglz.core.repository.property.PropertyBasedStateRepository
-
- All Implemented Interfaces:
StateRepository
- Direct Known Subclasses:
FileBasedStateRepository
public class PropertyBasedStateRepository extends Object implements StateRepository
This implementation ofStateRepositorystores the state of features in aPropertiesformat. The properties are managed through an implementation ofPropertySourceto manage the actual source of the property values.The file format has changed since version 2.0.0 because of the new extendable activation strategy support. Old file formats will be automatically migrated. The new format looks like this:
FEATURE_ONE = true FEATURE_ONE.strategy = gradual FEATURE_ONE.param.percentage = 25 FEATURE_TWO = false
A feature is enabled if the value is one of
true,yes,enable, orenabled; any other value and the feature is considered disabled.
-
-
Constructor Summary
Constructors Constructor Description PropertyBasedStateRepository(PropertySource propertySource)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FeatureStategetFeatureState(Feature feature)Get the persisted state of a feature from the repository.voidsetFeatureState(FeatureState featureState)Persist the supplied feature state.
-
-
-
Constructor Detail
-
PropertyBasedStateRepository
public PropertyBasedStateRepository(PropertySource propertySource)
-
-
Method Detail
-
getFeatureState
public FeatureState getFeatureState(Feature feature)
Description copied from interface:StateRepositoryGet the persisted state of a feature from the repository. If the repository doesn't contain any information regarding this feature it must returnnull.- Specified by:
getFeatureStatein interfaceStateRepository- Parameters:
feature- The feature to read the state for- Returns:
- The persisted feature state or
null
-
setFeatureState
public void setFeatureState(FeatureState featureState)
Description copied from interface:StateRepositoryPersist the supplied feature state. The repository implementation must ensure that subsequent calls toStateRepository.getFeatureState(Feature)return the same state as persisted using this method.- Specified by:
setFeatureStatein interfaceStateRepository- Parameters:
featureState- The feature state to persist
-
-