choco.kernel.model.variables
Class AbstractVariable
java.lang.Object
choco.kernel.model.VariableArray
choco.kernel.model.ModelObject
choco.kernel.model.variables.AbstractVariable
- All Implemented Interfaces:
- IPretty, IIndex, IConstraintList, IFindManager, IOptions, IVariableArray, IHook, Variable, Serializable, Comparable
- Direct Known Subclasses:
- ComponentVariable, MultipleVariables
public abstract class AbstractVariable
- extends ModelObject
- implements Variable, Comparable
Created by IntelliJ IDEA.
User: charles
Date: 17 mars 2008
Time: 18:28:35
Abstract class for variable with basic methods
- See Also:
- Serialized Form
Fields inherited from interface choco.kernel.model.variables.Variable |
LOGGER |
Fields inherited from interface choco.kernel.model.variables.IHook |
NO_HOOK |
Methods inherited from class choco.kernel.model.VariableArray |
cancelExtractVariables, doExtractVariables, extractVariables, forceExtractVariables, getNbVars, getVariable, getVariableIterator, getVariables, replaceBy, replaceByConstantAt, setVariables, setVariables |
type
protected final VariableType type
name
protected String name
AbstractVariable
public AbstractVariable(VariableType type,
boolean enableOption,
IConstraintList constraints)
AbstractVariable
public AbstractVariable(VariableType type,
boolean enableOptions)
AbstractVariable
public AbstractVariable(VariableType type,
Variable[] variables,
boolean enableOptions)
throwConstantException
protected static void throwConstantException()
getName
public final String getName()
- Specified by:
getName
in interface Variable
setName
public final void setName(String name)
getVariableType
public final VariableType getVariableType()
- Specified by:
getVariableType
in interface Variable
pretty
public String pretty()
- Description copied from interface:
IPretty
- pretty printing of the object. This String is not constant and may depend on the context.
- Specified by:
pretty
in interface IPretty
- Overrides:
pretty
in class VariableArray
- Returns:
- a readable string representation of the object
toString
public String toString()
- Overrides:
toString
in class ModelObject
- See Also:
Object.toString()
compareTo
public int compareTo(Object o)
- Compares this object with the specified object for order. Returns a
negative integer, zero, or a positive integer as this object is less
than, equal to, or greater than the specified object.
The implementor must ensure sgn(x.compareTo(y)) ==
-sgn(y.compareTo(x)) for all x and y. (This
implies that x.compareTo(y) must throw an exception iff
y.compareTo(x) throws an exception.)
The implementor must also ensure that the relation is transitive:
(x.compareTo(y)>0 && y.compareTo(z)>0) implies
x.compareTo(z)>0.
Finally, the implementor must ensure that x.compareTo(y)==0
implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for
all z.
It is strongly recommended, but not strictly required that
(x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any
class that implements the Comparable interface and violates
this condition should clearly indicate this fact. The recommended
language is "Note: this class has a natural ordering that is
inconsistent with equals."
In the foregoing description, the notation
sgn(expression) designates the mathematical
signum function, which is defined to return one of -1,
0, or 1 according to whether the value of
expression is negative, zero or positive.
- Specified by:
compareTo
in interface Comparable
- Parameters:
o
- the object to be compared.
- Returns:
- a negative integer, zero, or a positive integer as this object
is less than, equal to, or greater than the specified object.
- Throws:
ClassCastException
- if the specified object's type prevents it
from being compared to this object.
_addConstraint
public final void _addConstraint(Constraint c)
- Specified by:
_addConstraint
in interface IConstraintList
_removeConstraint
public final void _removeConstraint(Constraint c)
- Specified by:
_removeConstraint
in interface IConstraintList
_contains
public boolean _contains(Constraint c)
- Specified by:
_contains
in interface IConstraintList
getConstraintIterator
@Deprecated
public Iterator<Constraint> getConstraintIterator()
- Deprecated.
- Specified by:
getConstraintIterator
in interface Variable
getConstraintIterator
public final Iterator<Constraint> getConstraintIterator(Model m)
- Specified by:
getConstraintIterator
in interface IConstraintList
getConstraints
public Constraint[] getConstraints()
- Specified by:
getConstraints
in interface IConstraintList
getConstraint
public final Constraint getConstraint(int idx)
- Specified by:
getConstraint
in interface IConstraintList
getNbConstraint
@Deprecated
public int getNbConstraint()
- Deprecated.
- Specified by:
getNbConstraint
in interface Variable
getNbConstraint
public int getNbConstraint(Model m)
- Specified by:
getNbConstraint
in interface IConstraintList
removeConstraints
public void removeConstraints()
- Specified by:
removeConstraints
in interface IConstraintList
getHook
public final int getHook()
- Description copied from interface:
IHook
- get the current hook value
- Specified by:
getHook
in interface IHook
resetHook
public final void resetHook()
- Description copied from interface:
IHook
- reset the hook, it allows to set a new value.
- Specified by:
resetHook
in interface IHook
setHook
public final void setHook(int hook)
- Description copied from interface:
IHook
- you should be sure to reset the hook before setting a new hook value
- Specified by:
setHook
in interface IHook
- Parameters:
hook
- the new hook value
Copyright © 2012. All Rights Reserved.