Class StatefulState

  • All Implemented Interfaces:
    IState, IStateful

    public class StatefulState
    extends Object
    implements IState, IStateful
    Class used as a bridge between 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.

    • Method Detail

      • getType

        public String getType()
        Description copied from interface: IState
        Get the node type of this state.
        Specified by:
        getType in interface IState
        Returns:
        node type
      • getChild

        public StatefulState getChild​(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.
        Specified by:
        getChild in interface IState
        Parameters:
        type - node type
        Returns:
        child node or null if no such child exists
      • getAttributeKeys

        public String[] getAttributeKeys()
        Description copied from interface: IState
        Return an array with the attribute keys for this state.
        Specified by:
        getAttributeKeys in interface IState
        Returns:
        attribute keys
      • getAttribute

        public String getAttribute​(String key)
        Description copied from interface: IState
        Gets a named attribute value.
        Specified by:
        getAttribute in interface IState
        Parameters:
        key - attribute key
        Returns:
        attribute value
      • getChildren

        public StatefulState[] getChildren()
        Description copied from interface: IState
        Gets all child nodes.
        Specified by:
        getChildren in interface IState
        Returns:
        an array of child nodes
      • getChildren

        public StatefulState[] getChildren​(String type)
        Description copied from interface: IState
        Gets all child nodes of a named type.
        Specified by:
        getChildren in interface IState
        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.
        Specified by:
        saveTo in interface IStateful
        Parameters:
        state - Object to save state to. Since there is no way to check for existing data in the state object an unused one should normally be used.
      • 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