Package net.ssehub.easy.varModel.model
Class Constraint
- java.lang.Object
-
- net.ssehub.easy.varModel.model.ModelElement
-
- net.ssehub.easy.varModel.model.ContainableModelElement
-
- net.ssehub.easy.varModel.model.Constraint
-
- All Implemented Interfaces:
IDatatypeVisitable,IModelElement,IPartialEvaluable
- Direct Known Subclasses:
AnnotationAssignmentConstraint,AttachedConstraint,ConstraintVariableConstraint,DefaultConstraint,TypedConstraint
public class Constraint extends ContainableModelElement implements IPartialEvaluable
Class to create a rule-based constraint.- Author:
- heiko beck, Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceConstraint.IConstraintTypeBase type for (extensible) constraint types.static classConstraint.TypeThe conceptual type of the constraint.
-
Field Summary
Fields Modifier and Type Field Description private ConstraintSyntaxTreeconsSyntax
-
Constructor Summary
Constructors Constructor Description Constraint()Constructor for serialization.Constraint(java.lang.String name, ConstraintSyntaxTree consSyntax, IModelElement parent)Creates a new constraint from an already parsed syntax tree.Constraint(java.lang.String name, IModelElement parent)Constructor for a new Constraint.Constraint(ConstraintSyntaxTree consSyntax, IModelElement parent)Creates a new constraint from an already parsed syntax tree.Constraint(IModelElement parent)Constructor for a new Constraint.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(IModelVisitor visitor)Accept method for the visitor.private static java.lang.Stringcheck(ConstraintSyntaxTree cst)Checks a constraint syntax tree for validation properties.ConstraintcreateConstraint(ConstraintSyntaxTree consSyntax)Creates a new constraint with same properties but changed constraint syntax tree.java.lang.ObjectgetAttachedTo()Returns the element, e.g., type, the constraint is attached to.ConstraintSyntaxTreegetConsSyntax()Getter-Method for the ConstraintSyntaxTree.Constraint.IConstraintTypegetType()Returns the conceptual type of the constraint.booleanisBooleanConstraint()Returns whether this constraint is a boolean constraint.voidsetConsSyntax(ConstraintSyntaxTree consSyntax)Changes the constraint syntax tree.java.lang.StringtoString()-
Methods inherited from class net.ssehub.easy.varModel.model.ContainableModelElement
accept, getNameSpace, getParent, getProject, getQualifiedName, getTopLevelParent, isTopLevel, setParent
-
Methods inherited from class net.ssehub.easy.varModel.model.ModelElement
findAttribute, getComment, getName, getUniqueName, isTransparent, propagateAttribute, setComment, setName
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.varModel.model.IPartialEvaluable
getParent
-
-
-
-
Field Detail
-
consSyntax
private ConstraintSyntaxTree consSyntax
-
-
Constructor Detail
-
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(java.lang.String name, IModelElement parent)Constructor for a new Constraint.- Parameters:
name- the name of a constraintparent- 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 treeparent- 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(java.lang.String name, ConstraintSyntaxTree consSyntax, IModelElement parent) throws CSTSemanticExceptionCreates a new constraint from an already parsed syntax tree.- Parameters:
name- the name of a constraintconsSyntax- the constraint syntax treeparent- 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 Detail
-
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 java.lang.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:IPartialEvaluableAccept method for the visitor.- Specified by:
acceptin interfaceIModelElement- Specified by:
acceptin interfaceIPartialEvaluable- Parameters:
visitor- The visitor, which should process this model element.
-
isBooleanConstraint
public boolean isBooleanConstraint()
Returns whether this constraint is a boolean constraint.- Returns:
trueif it is a boolean constraint,falseotherwise (please note thatfalsedoes not even imply that this constraint is valid)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classModelElement
-
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 java.lang.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
-
-