Package org.openjdk.jmc.common.util
Class StatefulState
- java.lang.Object
-
- org.openjdk.jmc.common.util.StatefulState
-
public class StatefulState extends java.lang.Object implements IState, IStateful
Class used as a bridge betweenIStateful
andIState
. You can read individual values from it and you can pass the entire class to anIWritableState
to save all the values.Instances of this class should be immutable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
StatefulState.StatefulStateWriter
StatefulState instances should be kept immutable, so the writer must not be exposed.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.String>
attributes
private java.util.List<StatefulState>
children
private java.lang.String
type
-
Constructor Summary
Constructors Modifier Constructor Description private
StatefulState(java.lang.String type)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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()
-
-
-
Field Detail
-
type
private final java.lang.String type
-
attributes
private final java.util.Map<java.lang.String,java.lang.String> attributes
-
children
private final java.util.List<StatefulState> children
-
-
Method Detail
-
getType
public java.lang.String getType()
Description copied from interface:IState
Get the node type of this state.
-
getChild
public StatefulState getChild(java.lang.String type)
Description copied from interface:IState
Gets a child of the named type. If there are several child nodes of the same type then any of them may be returned.
-
getAttributeKeys
public java.lang.String[] getAttributeKeys()
Description copied from interface:IState
Return an array with the attribute keys for this state.- Specified by:
getAttributeKeys
in interfaceIState
- Returns:
- attribute keys
-
getAttribute
public java.lang.String getAttribute(java.lang.String key)
Description copied from interface:IState
Gets a named attribute value.- Specified by:
getAttribute
in interfaceIState
- Parameters:
key
- attribute key- Returns:
- attribute value
-
getChildren
public StatefulState[] getChildren()
Description copied from interface:IState
Gets all child nodes.- Specified by:
getChildren
in interfaceIState
- Returns:
- an array of child nodes
-
getChildren
public StatefulState[] getChildren(java.lang.String type)
Description copied from interface:IState
Gets all child nodes of a named type.- Specified by:
getChildren
in interfaceIState
- Parameters:
type
- node type- Returns:
- an array of child nodes
-
saveTo
public void saveTo(IWritableState state)
Description copied from interface:IStateful
Saves the state for this object into a state object.
-
create
public static StatefulState create(IStateful state)
Create a new instance.- Parameters:
state
- object whose state will be loaded into the new instance- Returns:
- a new state instance
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-