public class StatefulState extends java.lang.Object implements IState, IStateful
IStateful
and IState
. You can read individual
values from it and you can pass the entire class to an IWritableState
to save all the
values.
Instances of this class should be immutable.
Modifier and Type | Class and Description |
---|---|
private static class |
StatefulState.StatefulStateWriter
StatefulState instances should be kept immutable, so the writer must not be exposed.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.String> |
attributes |
private java.util.List<StatefulState> |
children |
private java.lang.String |
type |
Modifier | Constructor and Description |
---|---|
private |
StatefulState(java.lang.String type) |
Modifier and Type | Method and Description |
---|---|
static StatefulState |
create(IStateful state)
Create a new instance.
|
java.lang.String |
getAttribute(java.lang.String key)
Gets a named attribute value.
|
java.lang.String[] |
getAttributeKeys()
Return an array with the attribute keys for this state.
|
StatefulState |
getChild(java.lang.String type)
Gets a child of the named type.
|
StatefulState[] |
getChildren()
Gets all child nodes.
|
StatefulState[] |
getChildren(java.lang.String type)
Gets all child nodes of a named type.
|
java.lang.String |
getType()
Get the node type of this state.
|
void |
saveTo(IWritableState state)
Saves the state for this object into a state object.
|
java.lang.String |
toString() |
private final java.lang.String type
private final java.util.Map<java.lang.String,java.lang.String> attributes
private final java.util.List<StatefulState> children
public java.lang.String getType()
IState
public StatefulState getChild(java.lang.String type)
IState
public java.lang.String[] getAttributeKeys()
IState
getAttributeKeys
in interface IState
public java.lang.String getAttribute(java.lang.String key)
IState
getAttribute
in interface IState
key
- attribute keypublic StatefulState[] getChildren()
IState
getChildren
in interface IState
public StatefulState[] getChildren(java.lang.String type)
IState
getChildren
in interface IState
type
- node typepublic void saveTo(IWritableState state)
IStateful
public static StatefulState create(IStateful state)
state
- object whose state will be loaded into the new instancepublic java.lang.String toString()
toString
in class java.lang.Object