public class CompositeStateRepository extends Object implements StateRepository
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. *| Modifier and Type | Class and Description |
|---|---|
static class |
CompositeStateRepository.IterationOrder |
static interface |
CompositeStateRepository.RepositorySelector
Provides a means to select from a collection of state repositories.
|
static class |
CompositeStateRepository.SetterSelection |
| Constructor and Description |
|---|
CompositeStateRepository(StateRepository... repositories)
Creates a composite state repository using the specified underlying state
repositories.
|
| Modifier and Type | Method and Description |
|---|---|
FeatureState |
getFeatureState(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.
|
public CompositeStateRepository(StateRepository... repositories)
repositories - state repositoriespublic void setIterationOrder(CompositeStateRepository.RepositorySelector iterationOrder)
iterationOrder - the iteration orderCompositeStateRepository.IterationOrderpublic void setSetterSelection(CompositeStateRepository.RepositorySelector setterSelection)
setterSelection - the selectorCompositeStateRepository.SetterSelectionpublic FeatureState getFeatureState(Feature feature)
getFeatureState in interface StateRepositoryfeature - The feature to read the state fornullsetIterationOrder(RepositorySelector)public void setFeatureState(FeatureState featureState)
setFeatureState in interface StateRepositoryfeatureState - The feature state to persistsetSetterSelection(RepositorySelector)Copyright © 2018. All Rights Reserved.