Package ru.ispras.fortress.data
Class Variable
- java.lang.Object
-
- ru.ispras.fortress.data.Variable
-
public final class Variable extends java.lang.Object
TheVariable
class describes a variable that can be used as input or output data in constraints.
-
-
Constructor Summary
Constructors Constructor Description Variable(java.lang.String name, Data data)
Constructs a variable from its name and associated data.Variable(java.lang.String name, DataType type)
Constructs an uninitialized variable of the specified type.Variable(java.lang.String name, Value<Data> data)
Constructs a variable from its name and associated dynamic data.Variable(Variable variable)
Constructs a full copy of the given variable object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Data
getData()
Returns a data object associated with the specified variable.java.lang.String
getName()
Returns the name of the variable.DataType
getType()
Returns the type of the variable.int
hashCode()
boolean
hasValue()
Checks whether the variable has a value assigned to it.void
setData(Data data)
Assigns a new data value to the variable.java.lang.String
toString()
-
-
-
Constructor Detail
-
Variable
public Variable(java.lang.String name, Value<Data> data)
Constructs a 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 parameters equalsnull
.
-
Variable
public Variable(java.lang.String name, Data data)
Constructs a variable from its name and associated data.- Parameters:
name
- Variable name.data
- Data the variable refers to.- Throws:
java.lang.IllegalArgumentException
- if any of the parameters equalsnull
.
-
Variable
public Variable(java.lang.String name, DataType type)
Constructs an uninitialized variable of the specified type. The constructed variable does not refer to any data and its value is set tonull
.- Parameters:
name
- Variable name.type
- Variable type.- Throws:
java.lang.IllegalArgumentException
- if any of the parameters equalsnull
.
-
Variable
public Variable(Variable variable)
Constructs a full copy of the given variable object. The fields are copied by reference because their types are immutable.- Parameters:
variable
- Variable object to be copied.- Throws:
java.lang.IllegalArgumentException
- if the parameter equalsnull
.
-
-
Method Detail
-
setData
public void setData(Data data)
Assigns a new data value to the variable.- Parameters:
data
- A data value to be assigned to the variable.- Throws:
java.lang.IllegalArgumentException
- if the parameter equalsnull
.
-
getName
public java.lang.String getName()
Returns the name of the variable.- Returns:
- A string representing the variable name.
-
getData
public Data getData()
Returns a data object associated with the specified variable.- Returns:
- A
Data
object associated with the variable.
-
getType
public DataType getType()
Returns the type of the variable.- Returns:
- Variable type.
-
hasValue
public boolean hasValue()
Checks whether the variable has a value assigned to it.- Returns:
true
if the variable has a value assigned orfalse
otherwise.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-