Class CompositeStateRepository
java.lang.Object
org.togglz.core.repository.composite.CompositeStateRepository
- All Implemented Interfaces:
StateRepository
A
StateRepository
that is composed of one or more underlying
repositories. For getFeatureState(Feature)
this implementation
returns the first non-null value from the underlying repositories, searched
in the order specified during construction. The
setFeatureState(FeatureState)
method calls the corresponding method
on the last underlying repository.
If you don't want setFeatureState(FeatureState)
to update a
persistent repository, consider using an InMemoryStateRepository
as
the last argument. *-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static interface
Provides a means to select from a collection of state repositories.static enum
-
Constructor Summary
ConstructorsConstructorDescriptionCompositeStateRepository
(StateRepository... repositories) Creates a composite state repository using the specified underlying state repositories. -
Method Summary
Modifier and TypeMethodDescriptiongetFeatureState
(Feature feature) Returns the first non-null feature state as determined by the current iteration order.void
setFeatureState
(FeatureState featureState) Sets the feature state on the repositories returned by the current setter selection.void
setIterationOrder
(CompositeStateRepository.RepositorySelector iterationOrder) Sets the order this composite calls to get feature states.void
setSetterSelection
(CompositeStateRepository.RepositorySelector setterSelection) Sets the selector for which state repositories to call to set a feature state.
-
Constructor Details
-
CompositeStateRepository
Creates a composite state repository using the specified underlying state repositories.- Parameters:
repositories
- state repositories
-
-
Method Details
-
setIterationOrder
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:
-
setSetterSelection
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:
-
getFeatureState
Returns the first non-null feature state as determined by the current iteration order.- Specified by:
getFeatureState
in interfaceStateRepository
- Parameters:
feature
- The feature to read the state for- Returns:
- The persisted feature state or
null
- See Also:
-
setFeatureState
Sets the feature state on the repositories returned by the current setter selection.- Specified by:
setFeatureState
in interfaceStateRepository
- Parameters:
featureState
- The feature state to persist- See Also:
-