- 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 interface
A state which combines a number of states, either ANDing or ORing those together when determining its own state.static interface
AState.Group
deactivates 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.Combination
and
(StateObserver... stateObservers) Creates a newState.Combination
instance usingConjunction.AND
.static State.Combination
and
(Collection<? extends StateObserver> stateObservers) Creates a newState.Combination
instance usingConjunction.AND
.static State.Combination
combination
(Conjunction conjunction, StateObserver... stateObservers) Creates a newState.Combination
instance.static State.Combination
combination
(Conjunction conjunction, Collection<? extends StateObserver> stateObservers) Creates a newState.Combination
instance.static State.Group
Creates a newState.Group
instance, which guarantees that only a single state within the group is active at a timestatic State.Group
group
(Collection<State> states) Creates a newState.Group
instance, which guarantees that only a single state within the group is active at a timeobserver()
Returns aStateObserver
notified each time the state changesstatic State.Combination
or
(StateObserver... stateObservers) Creates a newState.Combination
instance usingConjunction.OR
.static State.Combination
or
(Collection<? extends StateObserver> stateObservers) Creates a newState.Combination
instance usingConjunction.OR
.static State
state()
Creates a new 'false'State
instance.static State
state
(boolean value) Creates a newState
instance.Methods inherited from interface is.codion.common.event.EventObserver
addDataListener, addListener, addWeakDataListener, addWeakListener, removeDataListener, removeListener, removeWeakDataListener, removeWeakListener
Methods inherited from interface is.codion.common.state.StateObserver
not
Methods inherited from interface is.codion.common.value.Value
accept, addValidator, link, link, removeValidator, set, unlink, unlink, validate
Methods inherited from interface is.codion.common.value.ValueObserver
equalTo, isNotNull, isNull, notEqualTo, nullable, optional
-
Method Details
-
observer
StateObserver observer()Returns aStateObserver
notified each time the state changes- Specified by:
observer
in interfaceValue<Boolean>
- Returns:
- a
StateObserver
notified each time the state changes
-
state
Creates a new 'false'State
instance.- Returns:
- a new
State
instance
-
state
Creates a newState
instance.- Parameters:
value
- the initial state value- Returns:
- a new
State
instance
-
combination
Creates a newState.Combination
instance.- Parameters:
conjunction
- the conjunction to usestateObservers
- the state observers to base this state combination on- Returns:
- a new
State.Combination
instance
-
combination
static State.Combination combination(Conjunction conjunction, Collection<? extends StateObserver> stateObservers) Creates a newState.Combination
instance.- Parameters:
conjunction
- the conjunction to usestateObservers
- the state observers to base this state combination on- Returns:
- a new
State.Combination
instance
-
and
Creates a newState.Combination
instance usingConjunction.AND
.- Parameters:
stateObservers
- the state observers to base this state combination on- Returns:
- a new
State.Combination
instance
-
and
Creates a newState.Combination
instance usingConjunction.AND
.- Parameters:
stateObservers
- the state observers to base this state combination on- Returns:
- a new
State.Combination
instance
-
or
Creates a newState.Combination
instance usingConjunction.OR
.- Parameters:
stateObservers
- the state observers to base this state combination on- Returns:
- a new
State.Combination
instance
-
or
Creates a newState.Combination
instance usingConjunction.OR
.- Parameters:
stateObservers
- the state observers to base this state combination on- Returns:
- a new
State.Combination
instance
-
group
Creates a newState.Group
instance, 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.Group
instance - See Also:
-
group
Creates a newState.Group
instance, 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.Group
instance - See Also:
-