- All Superinterfaces:
Consumer<Boolean>
,Observer<Boolean>
,StateObserver
,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.observer();
observer.addConsumer(this::onStateChange);
state.set(true);
state.set(false);
state.set(null); //translates to false
A factory for State
instances.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Builds aState
instance.static 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.BuilderFactory, 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.Builder
builder()
static State.Builder
builder
(boolean initialValue) 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 initialValue) Creates a newState
instance.Methods inherited from interface is.codion.common.observer.Observer
addConsumer, addListener, addWeakConsumer, addWeakListener, removeConsumer, removeListener, removeWeakConsumer, removeWeakListener
Methods inherited from interface is.codion.common.state.StateObserver
isNotNull, isNull, not, nullable
Methods inherited from interface is.codion.common.value.Value
accept, addValidator, clear, link, link, map, removeValidator, set, unlink, unlink, validate
Methods inherited from interface is.codion.common.value.ValueObserver
get, isEqualTo, isNotEqualTo, 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:
initialValue
- the initial state value- Returns:
- a new
State
instance
-
builder
- Returns:
- a new
State.Builder
instance
-
builder
- Parameters:
initialValue
- the initial value- Returns:
- a new
State.Builder
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:
-