javax.constraints.impl
Class AbstractConstraint

java.lang.Object
  extended by javax.constraints.impl.CommonBase
      extended by javax.constraints.impl.AbstractConstraint
All Implemented Interfaces:
Constraint
Direct Known Subclasses:
ConstraintElementAtOnSets, ConstraintFalse, ConstraintGlobalCardinality, ConstraintMax, ConstraintMin, ConstraintNotAllEqual, ConstraintTable, ConstraintTraceVar, ConstraintTrue

public abstract class AbstractConstraint
extends CommonBase
implements Constraint

This is a base implementation for all


Constructor Summary
AbstractConstraint(Problem problem)
           
AbstractConstraint(Problem problem, java.lang.String name)
           
 
Method Summary
 Constraint and(Constraint c)
          Returns an "AND" Constraint.
 VarBool asBool()
          This method returns a Var variable that is equal 1 if the constraint is satisfied and equals 0 if it is violated.
 Constraint implies(Constraint c)
          Returns a Constraint that states the implication: this => c.
 Constraint negation()
          Returns a Constraint that is satisfied if and only if this constraint is not satisfied.
 Constraint or(Constraint c)
          Returns an "OR" Constraint.
 void post()
          This method takes a constraint's implementation and uses its own RI-specific post-method.
 void post(ConsistencyLevel consistencyLevel)
          This method is used to post the constraint.
 
Methods inherited from class javax.constraints.impl.CommonBase
getImpl, getName, getObject, getProblem, setImpl, setName, setObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.constraints.Constraint
getImpl, getName, getObject, getProblem, setImpl, setName, setObject
 

Constructor Detail

AbstractConstraint

public AbstractConstraint(Problem problem)

AbstractConstraint

public AbstractConstraint(Problem problem,
                          java.lang.String name)
Method Detail

and

public Constraint and(Constraint c)
Returns an "AND" Constraint. The Constraint "AND" is satisfied if both of the Constraints "this" and "c" are satisfied. The Constraint "AND" is not satisfied if at least one of the Constraints "this" or "c" is not satisfied.

Specified by:
and in interface Constraint
Parameters:
c - the Constraint which is part of the new "AND" Constraint
Returns:
a Constraint "AND" between the Constraints "this" and "c2".

asBool

public VarBool asBool()
This method returns a Var variable that is equal 1 if the constraint is satisfied and equals 0 if it is violated. Each constraint that participates in logical expressions should implement this method.

Specified by:
asBool in interface Constraint
Returns:
Var with a domain [0;1]: a 1 value indicates the constraint is satisfied, a 0 value indicates the constraint is violated.

implies

public Constraint implies(Constraint c)
Returns a Constraint that states the implication: this => c. In other words, if this constraint is satisfied, then constraint "c" should also be satisfied.

Specified by:
implies in interface Constraint
Parameters:
c - the Constraint in the implication.
Returns:
a Constraint that means this => c (if this then c).

negation

public Constraint negation()
Returns a Constraint that is satisfied if and only if this constraint is not satisfied.

Specified by:
negation in interface Constraint
Returns:
a Constraint that is satisfied if and only if this constraint is not satisfied.

or

public Constraint or(Constraint c)
Returns an "OR" Constraint. The Constraint "OR" is satisfied if either of the Constraints "this" and "c" is satisfied. The Constraint "OR" is not satisfied if both of the Constraints "this" and "c" are not satisfied.

Specified by:
or in interface Constraint
Parameters:
c - the Constraint which is part of the new "OR" Constraint
Returns:
a Constraint "OR" between the Constraints "this" and "c".

post

public void post()
This method takes a constraint's implementation and uses its own RI-specific post-method.

Specified by:
post in interface Constraint
Throws:
java.lang.RuntimeException - if a failure happened during the posting

post

public void post(ConsistencyLevel consistencyLevel)
This method is used to post the constraint. Additionally to post() this methods specifies a particular level of consistency that will be selected by an implementation to control the propagation strength of this constraint. If this method is not overloaded by an implementation, it will work as a post().

Specified by:
post in interface Constraint
Parameters:
consistencyLevel -
Throws:
java.lang.RuntimeException - if a failure happened during the posting