- All Superinterfaces:
Consumer<Boolean>,EventObserver<Boolean>,StateObserver,Supplier<Boolean>,Value<Boolean>,ValueObserver<Boolean>
A class encapsulating a boolean state, non-nullable with null values translated to false.
State state = State.state(); StateObserver observer = state.getObserver(); observer.addDataListener(this::onStateChange); state.set(true); state.set(false); state.set(null); //translates to falseA factory class for
State objects.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA state which combines a number of states, either ANDing or ORing those together when determining its own state.static interfaceAState.Groupdeactivates all other states when a state in the group is activated.Nested classes/interfaces inherited from interface is.codion.common.value.Value
Value.Notify, Value.Validator<T> -
Method Summary
Modifier and TypeMethodDescriptionstatic State.Combinationand(StateObserver... stateObservers) Creates a newState.Combinationinstance usingConjunction.AND.static State.Combinationand(Collection<? extends StateObserver> stateObservers) Creates a newState.Combinationinstance usingConjunction.AND.static State.Combinationcombination(Conjunction conjunction, StateObserver... stateObservers) Creates a newState.Combinationinstance.static State.Combinationcombination(Conjunction conjunction, Collection<? extends StateObserver> stateObservers) Creates a newState.Combinationinstance.static State.GroupCreates a newState.Groupinstance, which guarantees that only a single state within the group is active at a timestatic State.Groupgroup(Collection<State> states) Creates a newState.Groupinstance, which guarantees that only a single state within the group is active at a timeobserver()Returns aStateObservernotified each time the state changesstatic State.Combinationor(StateObserver... stateObservers) Creates a newState.Combinationinstance usingConjunction.OR.static State.Combinationor(Collection<? extends StateObserver> stateObservers) Creates a newState.Combinationinstance usingConjunction.OR.static Statestate()Creates a new 'false'Stateinstance.static Statestate(boolean value) Creates a newStateinstance.Methods inherited from interface is.codion.common.event.EventObserver
addDataListener, addListener, addWeakDataListener, addWeakListener, removeDataListener, removeListener, removeWeakDataListener, removeWeakListenerMethods inherited from interface is.codion.common.state.StateObserver
notMethods inherited from interface is.codion.common.value.Value
accept, addValidator, link, link, map, mapNull, removeValidator, set, unlink, unlink, validateMethods inherited from interface is.codion.common.value.ValueObserver
isEqualTo, isNotEqualTo, isNotNull, isNull, nullable, optional
-
Method Details
-
observer
StateObserver observer()Returns aStateObservernotified each time the state changes- Specified by:
observerin interfaceValue<Boolean>- Returns:
- a
StateObservernotified each time the state changes
-
state
Creates a new 'false'Stateinstance.- Returns:
- a new
Stateinstance
-
state
Creates a newStateinstance.- Parameters:
value- the initial state value- Returns:
- a new
Stateinstance
-
combination
Creates a newState.Combinationinstance.- Parameters:
conjunction- the conjunction to usestateObservers- the state observers to base this state combination on- Returns:
- a new
State.Combinationinstance
-
combination
static State.Combination combination(Conjunction conjunction, Collection<? extends StateObserver> stateObservers) Creates a newState.Combinationinstance.- Parameters:
conjunction- the conjunction to usestateObservers- the state observers to base this state combination on- Returns:
- a new
State.Combinationinstance
-
and
Creates a newState.Combinationinstance usingConjunction.AND.- Parameters:
stateObservers- the state observers to base this state combination on- Returns:
- a new
State.Combinationinstance
-
and
Creates a newState.Combinationinstance usingConjunction.AND.- Parameters:
stateObservers- the state observers to base this state combination on- Returns:
- a new
State.Combinationinstance
-
or
Creates a newState.Combinationinstance usingConjunction.OR.- Parameters:
stateObservers- the state observers to base this state combination on- Returns:
- a new
State.Combinationinstance
-
or
Creates a newState.Combinationinstance usingConjunction.OR.- Parameters:
stateObservers- the state observers to base this state combination on- Returns:
- a new
State.Combinationinstance
-
group
Creates a newState.Groupinstance, which guarantees that only a single state within the group is active at a time- Parameters:
states- the states to add to the group initially, not required- Returns:
- a new
State.Groupinstance - See Also:
-
group
Creates a newState.Groupinstance, which guarantees that only a single state within the group is active at a time- Parameters:
states- the states to add to the group initially- Returns:
- a new
State.Groupinstance - See Also:
-