Class CompositeStateRepository
- java.lang.Object
-
- org.togglz.core.repository.composite.CompositeStateRepository
-
- All Implemented Interfaces:
StateRepository
public class CompositeStateRepository extends Object implements StateRepository
AStateRepositorythat is composed of one or more underlying repositories. ForgetFeatureState(Feature)this implementation returns the first non-null value from the underlying repositories, searched in the order specified during construction. ThesetFeatureState(FeatureState)method calls the corresponding method on the last underlying repository. If you don't wantsetFeatureState(FeatureState)to update a persistent repository, consider using anInMemoryStateRepositoryas the last argument. *
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCompositeStateRepository.IterationOrderstatic interfaceCompositeStateRepository.RepositorySelectorProvides a means to select from a collection of state repositories.static classCompositeStateRepository.SetterSelection
-
Constructor Summary
Constructors Constructor Description CompositeStateRepository(StateRepository... repositories)Creates a composite state repository using the specified underlying state repositories.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FeatureStategetFeatureState(Feature feature)Returns the first non-null feature state as determined by the current iteration order.voidsetFeatureState(FeatureState featureState)Sets the feature state on the repositories returned by the current setter selection.voidsetIterationOrder(CompositeStateRepository.RepositorySelector iterationOrder)Sets the order this composite calls to get feature states.voidsetSetterSelection(CompositeStateRepository.RepositorySelector setterSelection)Sets the selector for which state repositories to call to set a feature state.
-
-
-
Constructor Detail
-
CompositeStateRepository
public CompositeStateRepository(StateRepository... repositories)
Creates a composite state repository using the specified underlying state repositories.- Parameters:
repositories- state repositories
-
-
Method Detail
-
setIterationOrder
public void setIterationOrder(CompositeStateRepository.RepositorySelector iterationOrder)
Sets the order this composite calls to get feature states. If not set the default iteration order is first-in-first-out.- Parameters:
iterationOrder- the iteration order- See Also:
CompositeStateRepository.IterationOrder
-
setSetterSelection
public void setSetterSelection(CompositeStateRepository.RepositorySelector setterSelection)
Sets the selector for which state repositories to call to set a feature state. If not set the default is the last repository in this composite.- Parameters:
setterSelection- the selector- See Also:
CompositeStateRepository.SetterSelection
-
getFeatureState
public FeatureState getFeatureState(Feature feature)
Returns the first non-null feature state as determined by the current iteration order.- Specified by:
getFeatureStatein interfaceStateRepository- Parameters:
feature- The feature to read the state for- Returns:
- The persisted feature state or
null - See Also:
setIterationOrder(RepositorySelector)
-
setFeatureState
public void setFeatureState(FeatureState featureState)
Sets the feature state on the repositories returned by the current setter selection.- Specified by:
setFeatureStatein interfaceStateRepository- Parameters:
featureState- The feature state to persist- See Also:
setSetterSelection(RepositorySelector)
-
-