Class Constraint

All Implemented Interfaces:
IDatatypeVisitable, IModelElement, IPartialEvaluable

public class Constraint extends ContainableModelElement implements IPartialEvaluable
Class to create a rule-based constraint.
Author:
heiko beck, Holger Eichelberger
  • Field Details

  • Constructor Details

    • Constraint

      Constraint()
      Constructor for serialization.
    • Constraint

      public Constraint(IModelElement parent)
      Constructor for a new Constraint.
      Parameters:
      parent - the object, in which this specific one is embedded
    • Constraint

      public Constraint(String name, IModelElement parent)
      Constructor for a new Constraint.
      Parameters:
      name - the name of a constraint
      parent - the object, in which this specific one is embedded
    • Constraint

      public Constraint(ConstraintSyntaxTree consSyntax, IModelElement parent) throws CSTSemanticException
      Creates a new constraint from an already parsed syntax tree.
      Parameters:
      consSyntax - the constraint syntax tree
      parent - the object, in which this specific one is embedded
      Throws:
      CSTSemanticException - in case that the constraint semantics cannot be resolved or that the specified constraint does not evaluate to a boolean expression
    • Constraint

      public Constraint(String name, ConstraintSyntaxTree consSyntax, IModelElement parent) throws CSTSemanticException
      Creates a new constraint from an already parsed syntax tree.
      Parameters:
      name - the name of a constraint
      consSyntax - the constraint syntax tree
      parent - the object, in which this specific one is embedded
      Throws:
      CSTSemanticException - in case that the constraint semantics cannot be resolved or that the specified constraint does not evaluate to a boolean expression
  • Method Details

    • getConsSyntax

      public ConstraintSyntaxTree getConsSyntax()
      Getter-Method for the ConstraintSyntaxTree.
      Returns:
      the ConstraintSytnaxTree
    • setConsSyntax

      public void setConsSyntax(ConstraintSyntaxTree consSyntax) throws CSTSemanticException
      Changes the constraint syntax tree. [required as consequence of parent elements]
      Parameters:
      consSyntax - the constraint syntax tree
      Throws:
      CSTSemanticException - in case that the constraint semantics cannot be resolved or that the specified constraint does not evaluate to a boolean expression
    • check

      private static String check(ConstraintSyntaxTree cst) throws CSTSemanticException
      Checks a constraint syntax tree for validation properties.
      Parameters:
      cst - the constraint syntax tree to be checked
      Returns:
      null in case of no error, the error description in case of an error
      Throws:
      CSTSemanticException - in case that the constraint semantics cannot be resolved or that the specified constraint does not evaluate to a boolean expression
    • accept

      public void accept(IModelVisitor visitor)
      Description copied from interface: IPartialEvaluable
      Accept method for the visitor.
      Specified by:
      accept in interface IModelElement
      Specified by:
      accept in interface IPartialEvaluable
      Parameters:
      visitor - The visitor, which should process this model element.
    • isBooleanConstraint

      public boolean isBooleanConstraint()
      Returns whether this constraint is a boolean constraint.
      Returns:
      true if it is a boolean constraint, false otherwise (please note that false does not even imply that this constraint is valid)
    • toString

      public String toString()
      Overrides:
      toString in class ModelElement
    • getType

      public Constraint.IConstraintType getType()
      Returns the conceptual type of the constraint. Reasoners may return specialized types here.
      Returns:
      the conceptual type (Constraint.Type.USUAL)
    • getAttachedTo

      public Object getAttachedTo()
      Returns the element, e.g., type, the constraint is attached to. Reasoner may return specialized values here.
      Returns:
      the attached object (null always)
    • createConstraint

      public Constraint createConstraint(ConstraintSyntaxTree consSyntax) throws CSTSemanticException
      Creates a new constraint with same properties but changed constraint syntax tree.
      Parameters:
      consSyntax - the syntax tree
      Returns:
      the new constraint
      Throws:
      CSTSemanticException - in case that the constraint semantics cannot be resolved or that the specified constraint does not evaluate to a boolean expression