Class NodeState
There are three types of state: transient, secure and shared. Shared state is non-sensitive state, secure state is decrypted transient state and transient state is sensitive state that will be encrypted on round trips to the client.
This class encapsulates all three types of state to abstract from where a node's implementation decides to store its state based on each state's properties. Callers to this class should not know or care what type of state a particular piece of state is stored, only that it can be retrieved. This class also exposes the ability for callers to add state to either the shared state (non-sensitive) or transient state (sensitive).
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Wildcard state filter that allows access to all state. -
Method Summary
Modifier and TypeMethodDescriptionGets the value for the given key from the state.Get the value for the given key from the state.boolean
Checks if the given key is defined in any of the types of state.keys()
Gets the distinct keys from across all types of state.Puts the given key/value pair in the shared state.putTransient
(String key, Object value) Puts the given key/value pair in the transient state.void
Removes the given key from all states.
-
Field Details
-
STATE_FILTER_WILDCARD
Wildcard state filter that allows access to all state.- See Also:
-
-
Method Details
-
get
Gets the value for the given key from the state.The order of state types checked is the following:
- transient
- secure
- shared
- Parameters:
key
- The key.- Returns:
- The value or
null
if the key is not defined.
-
getObject
Get the value for the given key from the state. Combines state from transient, secure and shared when values are maps into an immutable object.- Parameters:
key
- The key.- Returns:
- The value or null if the key is not defined.
-
isDefined
Checks if the given key is defined in any of the types of state.- Parameters:
key
- The key.- Returns:
true
if the key is defined, otherwisefalse
.
-
keys
Gets the distinct keys from across all types of state.- Returns:
- The set of all keys.
-
putTransient
Puts the given key/value pair in the transient state.The transient state should only be used for sensitive information that will be encrypted on round trips to the client.
- Parameters:
key
- The key.value
- The value.- Returns:
- This modified
NodeState
instance.
-
remove
Removes the given key from all states.- Parameters:
key
- The key to remove.
-