Package org.eclipse.epsilon.evl.dom
Class ConstraintContext
- java.lang.Object
-
- org.eclipse.epsilon.common.module.AbstractModuleElement
-
- org.eclipse.epsilon.eol.dom.AnnotatableModuleElement
-
- org.eclipse.epsilon.evl.dom.ConstraintContext
-
- All Implemented Interfaces:
ModuleElement
,IExecutableModuleElement
,IExecutableModuleElementParameter
- Direct Known Subclasses:
GlobalConstraintContext
public class ConstraintContext extends AnnotatableModuleElement implements IExecutableModuleElement, IExecutableModuleElementParameter
-
-
Field Summary
Fields Modifier and Type Field Description protected ArrayList<Constraint>
constraints
protected ExecutableBlock<Boolean>
guardBlock
protected EolModelElementType
type
protected TypeExpression
typeExpression
-
Fields inherited from class org.eclipse.epsilon.eol.dom.AnnotatableModuleElement
annotationBlock
-
-
Constructor Summary
Constructors Constructor Description ConstraintContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(IEvlVisitor visitor)
boolean
appliesTo(Object object, IEvlContext context)
boolean
appliesTo(Object object, IEvlContext context, boolean checkType)
void
build(AST cst, IModule module)
boolean
equals(Object other)
boolean
execute(Object modelElement, IEvlContext context)
Executes all of this ConstraintContext's constraints for the given element.boolean
execute(Collection<Constraint> constraintsToCheck, Object modelElement, IEvlContext context)
Executes all constraints for the given model element, provided it is applicable to this ConstraintContext and that this ConstraintContext is not lazy.void
execute(Collection<Constraint> constraintsToCheck, IEvlContext context)
Executes all of the give constraints for all applicable elements of this type.Object
execute(IEolContext context)
Object
execute(IEolContext context_, Object self)
Collection<?>
getAllOfSourceKind(IEolContext context)
Collection<?>
getAllOfSourceType(IEolContext context)
List<Constraint>
getConstraints()
ExecutableBlock<Boolean>
getGuardBlock()
EolModelElementType
getType(IEolContext context)
TypeExpression
getTypeExpression()
String
getTypeName()
int
hashCode()
boolean
isLazy(IEvlContext context)
An entire context is lazy if all constraints are lazy, or if it is itself marked as lazy.boolean
isOfSourceKind(Object modelElement, IEvlContext context)
Checks if the given model element is an instance of the kind described by this ConstraintContext.boolean
isOfSourceType(Object modelElement, IEvlContext context)
Checks if the given model element is an instance of the type described by this ConstraintContext.void
setGuardBlock(ExecutableBlock<Boolean> guardBlock)
boolean
shouldBeChecked(Object modelElement, IEvlContext context)
String
toString()
-
Methods inherited from class org.eclipse.epsilon.eol.dom.AnnotatableModuleElement
accept, getAnnotation, getAnnotationBlock, getAnnotations, getAnnotationsValues, getBooleanAnnotationValue, getBooleanAnnotationValue, getBooleanAnnotationValue, getBooleanAnnotationValue, hasAnnotation, setAnnotationBlock
-
Methods inherited from class org.eclipse.epsilon.common.module.AbstractModuleElement
getChildren, getComments, getData, getDebugInfo, getFile, getModule, getParent, getRegion, getUri, setModule, setParent, setRegion, setUri
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.epsilon.common.module.ModuleElement
getChildren, getComments, getData, getFile, getModule, getParent, getRegion, getUri, setModule, setParent, setRegion, setUri
-
-
-
-
Field Detail
-
constraints
protected final ArrayList<Constraint> constraints
-
typeExpression
protected TypeExpression typeExpression
-
guardBlock
protected ExecutableBlock<Boolean> guardBlock
-
type
protected EolModelElementType type
-
-
Method Detail
-
build
public void build(AST cst, IModule module)
- Specified by:
build
in interfaceModuleElement
- Overrides:
build
in classAnnotatableModuleElement
-
shouldBeChecked
public boolean shouldBeChecked(Object modelElement, IEvlContext context) throws EolRuntimeException
- Parameters:
modelElement
-context
-- Returns:
- Throws:
EolRuntimeException
- Since:
- 1.6
-
isOfSourceType
public boolean isOfSourceType(Object modelElement, IEvlContext context) throws EolRuntimeException
Checks if the given model element is an instance of the type described by this ConstraintContext.- Parameters:
modelElement
- The model element.context
- The execution context containing the model(s).- Returns:
true
if the object's type is equal to this ConstraintContext's type.- Throws:
EolRuntimeException
- Since:
- 1.6
-
isOfSourceKind
public boolean isOfSourceKind(Object modelElement, IEvlContext context) throws EolRuntimeException
Checks if the given model element is an instance of the kind described by this ConstraintContext.- Parameters:
modelElement
- The model element.context
- The execution context containing the model(s).- Returns:
true
if the model element is compatible with this ConstraintContext.- Throws:
EolRuntimeException
- Since:
- 1.6
-
appliesTo
public final boolean appliesTo(Object object, IEvlContext context) throws EolRuntimeException
- Throws:
EolRuntimeException
-
appliesTo
public boolean appliesTo(Object object, IEvlContext context, boolean checkType) throws EolRuntimeException
- Throws:
EolRuntimeException
-
isLazy
public boolean isLazy(IEvlContext context) throws EolRuntimeException
An entire context is lazy if all constraints are lazy, or if it is itself marked as lazy.- Throws:
EolRuntimeException
-
getTypeName
public String getTypeName()
-
getConstraints
public List<Constraint> getConstraints()
-
getTypeExpression
public TypeExpression getTypeExpression()
-
getAllOfSourceType
public Collection<?> getAllOfSourceType(IEolContext context) throws EolModelElementTypeNotFoundException, EolModelNotFoundException
-
getAllOfSourceKind
public Collection<?> getAllOfSourceKind(IEolContext context) throws EolModelElementTypeNotFoundException, EolModelNotFoundException
-
getType
public EolModelElementType getType(IEolContext context) throws EolModelNotFoundException, EolModelElementTypeNotFoundException
-
execute
public boolean execute(Collection<Constraint> constraintsToCheck, Object modelElement, IEvlContext context) throws EolRuntimeException
Executes all constraints for the given model element, provided it is applicable to this ConstraintContext and that this ConstraintContext is not lazy.- Parameters:
constraintsToCheck
- The constraints, which may be a subset of this ConstraintContext's children.modelElement
- The model element object.context
- The execution context.- Returns:
- Whether the constraints were checked.
- Throws:
EolRuntimeException
- Since:
- 1.6
-
execute
public void execute(Collection<Constraint> constraintsToCheck, IEvlContext context) throws EolRuntimeException
Executes all of the give constraints for all applicable elements of this type.- Parameters:
constraintsToCheck
- The Constraints, which may be a subset of this ConstraintContext's children.context
- The execution context.- Throws:
EolRuntimeException
- Since:
- 1.6
-
execute
public boolean execute(Object modelElement, IEvlContext context) throws EolRuntimeException
Executes all of this ConstraintContext's constraints for the given element.- Parameters:
modelElement
- The model element object.context
- The execution context.- Throws:
EolRuntimeException
- Since:
- 1.6
-
execute
public Object execute(IEolContext context_, Object self) throws EolRuntimeException
- Specified by:
execute
in interfaceIExecutableModuleElementParameter
- Parameters:
context_
- The EVL execution context.- Returns:
- nothing.
- Throws:
EolRuntimeException
- Since:
- 1.6
-
execute
public Object execute(IEolContext context) throws EolRuntimeException
- Specified by:
execute
in interfaceIExecutableModuleElement
- Throws:
EolRuntimeException
- Since:
- 1.6
-
toString
public String toString()
- Overrides:
toString
in classAbstractModuleElement
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractModuleElement
- Since:
- 1.6
-
equals
public boolean equals(Object other)
- Overrides:
equals
in classAbstractModuleElement
- Since:
- 1.6
-
accept
public void accept(IEvlVisitor visitor)
-
getGuardBlock
public ExecutableBlock<Boolean> getGuardBlock()
-
setGuardBlock
public void setGuardBlock(ExecutableBlock<Boolean> guardBlock)
-
-