Class State

  • All Implemented Interfaces:
    Cloneable

    public final class State
    extends Object
    implements Cloneable
    Represents a state of a variable. E.g. the discrete variable Gender might have two states, Male and Female. Note that a continuous variable always has a single state.
    • Constructor Detail

      • State

        public State()
        Initializes a new instance of the State class.
      • State

        public State​(String name)
        Initializes a new instance of the State class with the specified [name].
        Parameters:
        name - The name for the state. Can be null.
      • State

        public State​(String name,
                     Object value)
        Initializes a new instance of the State class with the specified [name] and [value].
        Parameters:
        name - The name for the state. Can be null.
        value - Optional value for the state. When the state is added to a variable, this value must be compatible with the StateValueType set on the variable.
    • Method Detail

      • getCustomProperties

        public CustomPropertyCollection getCustomProperties()
        Gets custom properties associated with this instance. Custom properties allow storage of custom information, which will be saved with the network.
      • getDescription

        public String getDescription()
        Gets an optional description for the state.
      • setDescription

        public void setDescription​(String value)
        Sets an optional description for the state.
      • getIndex

        public int getIndex()
        Gets the index of the state in a variable's Variable.getStates() collection. Equals -1 if the State does not belong to a variable.
      • getName

        public String getName()
        Gets the name of the state.
      • setName

        public void setName​(String value)
        Sets the name of the state.
      • getValue

        public Object getValue()
        Gets an optional value for a state, such as an interval for discretized variables. When a State is added to a Variable this value must be compatible with the StateValueType set on the variable.
      • setValue

        public void setValue​(Object value)
        Sets an optional value for a state, such as an interval for discretized variables. When a State is added to a Variable this value must be compatible with the StateValueType set on the variable.
      • getVariable

        public Variable getVariable()
        Gets the Variable the state belongs to, if any. If this instance is a child of another state, the state hierarchy is traversed to reach the variable of the root state, if any.
        Returns:
        The Variable that this instance belongs to. Can be null.
      • copy

        public State copy()
        Copies this instance.
        Returns:
        A new State instance.
      • toString

        public String toString()
        Returns the name of the state, or an empty string if the name is null.
        Overrides:
        toString in class Object
        Returns:
        A String containing the name of the state which is empty if the name is null.