Class NodeVariable


  • public final class NodeVariable
    extends Node
    The NodeVariable class represents a node that refers to a variable which is specified as an attribute of a constraint. The class serves as an adapter to allow Variable objects to be used in an expression tree. The variable is unknown or has a value.
    • Constructor Detail

      • NodeVariable

        public NodeVariable​(java.lang.String name,
                            Value<Data> data)
        Constructs a node variable from its name and associated dynamic data. Used for creating context-dependent variables.
        Parameters:
        name - Variable name.
        data - Dynamic value.
        Throws:
        java.lang.IllegalArgumentException - if any of the arguments is null.
      • NodeVariable

        public NodeVariable​(java.lang.String name,
                            DataType type)
        Constructs a node for an uninitialized variable of the specified type. The constructed variable does not hold any data and its value is set to null.
        Parameters:
        name - Variable name.
        type - Variable type.
        Throws:
        java.lang.IllegalArgumentException - if any of the arguments is null.
      • NodeVariable

        public NodeVariable​(java.lang.String name,
                            Data value)
        Constructs a node for a variable that holds the specified value.
        Parameters:
        name - Variable name.
        value - Variable value.
        Throws:
        java.lang.IllegalArgumentException - if any of the arguments is null.
      • NodeVariable

        public NodeVariable​(Variable variable)
        Creates a node based on a Variable object.
        Parameters:
        variable - A variable node object.
        Throws:
        java.lang.IllegalArgumentException - if the argument is null.
    • Method Detail

      • newInteger

        public static NodeVariable newInteger​(java.lang.String name)
        Creates a new integer variable.
        Parameters:
        name - Variable name.
        Returns:
        New variable node.
        Throws:
        java.lang.IllegalArgumentException - if the argument is null.
      • newReal

        public static NodeVariable newReal​(java.lang.String name)
        Creates a new real variable.
        Parameters:
        name - Variable name.
        Returns:
        New variable node.
        Throws:
        java.lang.IllegalArgumentException - if the argument is null.
      • newString

        public static NodeVariable newString​(java.lang.String name)
        Creates a new string variable.
        Parameters:
        name - Variable name.
        Returns:
        New variable node.
        Throws:
        java.lang.IllegalArgumentException - if the argument is null.
      • newBoolean

        public static NodeVariable newBoolean​(java.lang.String name)
        Creates a new boolean variable.
        Parameters:
        name - Variable name.
        Returns:
        New variable node.
        Throws:
        java.lang.IllegalArgumentException - if the argument is null.
      • newUnknown

        public static NodeVariable newUnknown​(java.lang.String name)
        Creates a new variable of unknown type.
        Parameters:
        name - Variable name.
        Returns:
        New variable node.
        Throws:
        java.lang.IllegalArgumentException - if the argument is null.
      • newBitVector

        public static NodeVariable newBitVector​(java.lang.String name,
                                                int size)
        Creates a new bit vector variable.
        Parameters:
        name - Variable name.
        size - Bit vector size in bits.
        Returns:
        New variable node.
        Throws:
        java.lang.IllegalArgumentException - if the name argument is null or if the size argument is <= 0.
      • newMap

        public static NodeVariable newMap​(java.lang.String name,
                                          DataType keyType,
                                          DataType valueType)
        Creates a map-based variable.
        Parameters:
        name - Variable name.
        keyType - Key type.
        valueType - Value type.
        Returns:
        New variable node.
        Throws:
        java.lang.IllegalArgumentException - if any of the arguments is null.
      • deepCopy

        public Node deepCopy()
        Description copied from class: Node
        Creates a deep copy of the current objects. All aggregated objects that are not readonly must be cloned. This excludes user data as its type is unknown.
        Specified by:
        deepCopy in class Node
        Returns:
        Full copy of the current node object.
      • getVariable

        public Variable getVariable()
        Returns the variable associated with the node.
        Returns:
        Variable associated with the node.
      • getName

        public java.lang.String getName()
        Returns the name of the variable.
        Returns:
        The variable name.
      • getData

        public Data getData()
        Returns the data object that encapsulates the variable value.
        Returns:
        A data object.
      • setData

        public void setData​(Data data)
        Assigns new data value to the variable.
        Parameters:
        data - Data value to be assigned to the variable.
        Throws:
        java.lang.IllegalArgumentException - if the argument is null.
      • getValue

        public java.lang.Object getValue()
        Returns an object that stores a data value if any value was assigned to the variable (it is a known variable) or null if it is an unknown variable. The exact type of the object returned by the method depends on the implementation. Please see the DataTypeId enumeration for details on internal representation of data objects
        Returns:
        Object that stores the variable value if it is assigned or null otherwise
      • getDataType

        public DataType getDataType()
        Description copied from class: Node
        Returns an object that describes the type of the value referred by the node.
        Specified by:
        getDataType in class Node
        Returns:
        A data type object.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object