- All Superinterfaces:
Observable<Boolean>
,ObservableState
,Observer<Boolean>
,Value<Boolean>
A class encapsulating a boolean state, non-nullable with null values translated to false.
A factory for
State state = State.state();
ObservableState observable = state.observable();
observer.addConsumer(this::onStateChange);
state.set(true);
state.set(false);
state.set(null); //translates to false
State
instances.- See Also:
-
Nested Class Summary
Nested ClassesModifier 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
(ObservableState... observableStates) Creates a newState.Combination
instance usingConjunction.AND
.static State.Combination
and
(Collection<? extends ObservableState> observableStates) Creates a newState.Combination
instance usingConjunction.AND
.static State.Builder
builder()
static State.Builder
builder
(boolean value) static State.Combination
combination
(Conjunction conjunction, ObservableState... observableStates) Creates a newState.Combination
instance.static State.Combination
combination
(Conjunction conjunction, Collection<? extends ObservableState> observableStates) Creates a newState.Combination
instance.get()
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 timeReturns anObservableState
notified each time the state changesstatic State.Combination
or
(ObservableState... observableStates) Creates a newState.Combination
instance usingConjunction.OR
.static State.Combination
or
(Collection<? extends ObservableState> observableStates) 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.observable.Observable
addConsumer, addListener, addWeakConsumer, addWeakListener, getOrThrow, getOrThrow, isEqualTo, isNotEqualTo, observer, optional, removeConsumer, removeListener, removeWeakConsumer, removeWeakListener
Methods inherited from interface is.codion.common.state.ObservableState
isNull, isNullable, not
-
Method Details
-
get
- Specified by:
get
in interfaceObservable<Boolean>
- Specified by:
get
in interfaceObservableState
- Returns:
- the value
-
observable
ObservableState observable()Returns anObservableState
notified each time the state changes- Specified by:
observable
in interfaceValue<Boolean>
- Returns:
- an
ObservableState
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
-
builder
- Returns:
- a new
State.Builder
instance
-
builder
- Parameters:
value
- the initial value- Returns:
- a new
State.Builder
instance
-
combination
Creates a newState.Combination
instance.- Parameters:
conjunction
- the conjunction to useobservableStates
- the state observers to base this state combination on- Returns:
- a new
State.Combination
instance
-
combination
static State.Combination combination(Conjunction conjunction, Collection<? extends ObservableState> observableStates) Creates a newState.Combination
instance.- Parameters:
conjunction
- the conjunction to useobservableStates
- the state observers to base this state combination on- Returns:
- a new
State.Combination
instance
-
and
Creates a newState.Combination
instance usingConjunction.AND
.- Parameters:
observableStates
- the state observers to base this state combination on- Returns:
- a new
State.Combination
instance
-
and
Creates a newState.Combination
instance usingConjunction.AND
.- Parameters:
observableStates
- the state observers to base this state combination on- Returns:
- a new
State.Combination
instance
-
or
Creates a newState.Combination
instance usingConjunction.OR
.- Parameters:
observableStates
- the state observers to base this state combination on- Returns:
- a new
State.Combination
instance
-
or
Creates a newState.Combination
instance usingConjunction.OR
.- Parameters:
observableStates
- 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:
-