Class Constraint
- java.lang.Object
-
- ru.ispras.fortress.solver.constraint.Constraint
-
public final class Constraint extends java.lang.Object
TheConstraint
class stores a description of a constraint and provides facilities to perform manipulations with it. The Constraint class allows describing various constraint types. Depending on the constraint type (described by the kind field), its internal representation (see the representation field) can use a different class to store the information.
-
-
Constructor Summary
Constructors Constructor Description Constraint(java.lang.String name, ConstraintKind kind, java.lang.String description, java.util.Map<java.lang.String,Variable> variables, java.lang.Object representation)
Constructs a Constraint object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Variable
findVariable(java.lang.String name)
Finds a constraint variable by its name.java.lang.String
getDescription()
Returns the description of the constraint (some additional information).java.lang.Object
getInnerRep()
Returns an object that holds internal description of the constraint.ConstraintKind
getKind()
Returns information on the constraint type (including the format of its internals).java.lang.String
getName()
Returns the name that uniquely identifies a constraint.java.util.Collection<Variable>
getUnknownVariables()
Returns a collection of unknown constraint variables (that have no assigned value).java.util.Collection<Variable>
getVariables()
Returns a collection of constraint variables.int
hashCode()
void
setVariableValue(java.lang.String name, Data value)
Assigns a value to a constraint variable (makes it an input variable).java.lang.String
toString()
-
-
-
Constructor Detail
-
Constraint
public Constraint(java.lang.String name, ConstraintKind kind, java.lang.String description, java.util.Map<java.lang.String,Variable> variables, java.lang.Object representation)
Constructs a Constraint object.- Parameters:
name
- Constraint name (uniquely identifies the constraint).kind
- Constraint type (gives information about its internal representation format).description
- Constraint description.variables
- Table of constraint variables.representation
- Description of the constraint internals (internal representation) in a format that depends on the type of the constraint.- Throws:
java.lang.IllegalArgumentException
- if any of the parameters equals null.java.lang.IllegalArgumentException
- if the internal representation class does not match the class required by the constraint type.
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the name that uniquely identifies a constraint.- Returns:
- Name identifier for the constraint
-
getKind
public ConstraintKind getKind()
Returns information on the constraint type (including the format of its internals).- Returns:
- Constraint type information.
-
getDescription
public java.lang.String getDescription()
Returns the description of the constraint (some additional information).- Returns:
- Textual description of the constraint.
-
getInnerRep
public java.lang.Object getInnerRep()
Returns an object that holds internal description of the constraint. The exact type of the object depends on the constraint type.- Returns:
- Internal representation of the constraint.
-
setVariableValue
public void setVariableValue(java.lang.String name, Data value)
Assigns a value to a constraint variable (makes it an input variable).- Parameters:
name
- The name of the variable.value
- The data object that stores the variable value.- Throws:
java.lang.IllegalArgumentException
- if any of the parameters equals null.java.lang.IllegalArgumentException
- (1) if a variable with such name is not defined; (2) if the value type does not match the type of the variable.
-
findVariable
public Variable findVariable(java.lang.String name)
Finds a constraint variable by its name. If no such variable is found, null is returned.- Parameters:
name
- The name of the variable to be searched for.- Returns:
- variable Variable object or null if the variable is not defined.
- Throws:
java.lang.IllegalArgumentException
- if the name parameter equals null.
-
getVariables
public java.util.Collection<Variable> getVariables()
Returns a collection of constraint variables.- Returns:
- variables A collection of constraint variables.
-
getUnknownVariables
public java.util.Collection<Variable> getUnknownVariables()
Returns a collection of unknown constraint variables (that have no assigned value).- Returns:
- A collection of constraint variables.
-
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
-
-