
public class StateBundle extends Object implements Serializable, Cloneable
Enum.
States are stored internally in a ConcurrentHashMap, mapped by their class names.
This class is meant to be published on the buses with every status message
and when there is any state change.
This class is thread safe to the extent supported by the underlying ConcurrentHashMap:
no concurrent modifications are thrown, but atomicity of operations that involve
reading or modifying more than one elemental state is not guaranteed.| Constructor and Description |
|---|
StateBundle(Enum... states)
Constructs a StateBundle from a set of states.
|
| Modifier and Type | Method and Description |
|---|---|
StateBundle |
clone() |
StateBundle |
diffState(StateBundle oldState)
Finds what has changed.
|
boolean |
equals(Object o) |
Map<String,String> |
getInternalStates()
Gets string representations of the internal states.
|
Instant |
getLastModified()
Get the
Instant of the last time the StateBundle
was modified. |
<T extends Enum<T>> |
getState(Class<T> enumClass)
Returns the current value for the specified State.
|
int |
hashCode() |
boolean |
isInState(StateBundle stateBundle)
Check if this StateBundle is in all the states of a given StateBundle.
|
<T extends Enum<T>> |
isInState(T state)
Check if this
StateBundle contains the specified state. |
StateBundle |
mergeState(StateBundle newState)
Merge the content of two StateBundle objects returning an updated cloned
version of the original StateBundle object.
|
void |
setState(Enum... states)
Sets specified states to the bundle, replacing any previous states of the same types.
|
void |
setState(Enum state)
Sets the specified state to the bundle, replacing any previous state of the same type.
|
String |
toString() |
public StateBundle(Enum... states)
states - The set of States to construct the StateBundle with.public StateBundle mergeState(StateBundle newState)
newState - The StateBundle with the changes.public StateBundle diffState(StateBundle oldState)
oldState - The StateBundle of the previous state .public final void setState(Enum state)
state - The state to set on the StateBundle.public final void setState(Enum... states)
states - The specified states to set on the StateBundlepublic final <T extends Enum<T>> Enum getState(Class<T> enumClass)
T - An Enum that defines a set of states.enumClass - The class of the Enum representing the state.public <T extends Enum<T>> boolean isInState(T state)
StateBundle contains the specified state.T - An Enum that defines a set of states.state - The value of the Enum to check.StateBundle contains the provided statepublic boolean isInState(StateBundle stateBundle)
stateBundle - The StateBundle containing all the states to check.public Instant getLastModified()
Instant of the last time the StateBundle
was modified.Instant of the last changepublic Map<String,String> getInternalStates()
public StateBundle clone()
Copyright © 2016 LSST. All rights reserved.