Class AbstractRuleMatchExpression
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.expressions.Expression
-
- net.ssehub.easy.instantiation.core.model.buildlangModel.ruleMatch.AbstractRuleMatchExpression
-
- Direct Known Subclasses:
AbstractPathRuleMatchExpression,ArtifactMatchExpression,BooleanMatchExpression,CollectionMatchExpression
public abstract class AbstractRuleMatchExpression extends Expression
Represents a rule pre/post match condition (not a rule call in a pre condition). This class supports iterating over the match results.- Author:
- Holger Eichelberger
-
-
Constructor Summary
Constructors Constructor Description AbstractRuleMatchExpression()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.lang.Objectaccept(IMatchVisitor visitor)Accepts the given visitor for visiting.java.lang.Objectaccept(IExpressionVisitor visitor)Visits the expression.abstract booleancontributesTo(AbstractRuleMatchExpression expression)Returns whether this rule match expression may contribute to the fulfillment ofexpression.abstract java.lang.ObjectdetermineExpected(AbstractRuleMatchExpression rhsExpr, java.lang.Object rhsValue)Determines the expected value on the left side (represented by this object) based on the actual value for the corresponding right side.protected static TypeDescriptor<? extends Collection<? extends IArtifact>>ensureType(TypeDescriptor<?> type)Ensures a collection type fortype.abstract Collection<?>evaluate(IExpressionVisitor evaluator)Evaluates this expression.abstract TypeDescriptor<?>getEntryType()Returns the entry type over which this match expression will be able to iterate.TypeDescriptor<? extends Collection<? extends IArtifact>>inferType()Infers the type of this expression including the type of the contained sub-expressions.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.Expression
replaceEmptyLine
-
-
-
-
Method Detail
-
getEntryType
public abstract TypeDescriptor<?> getEntryType()
Returns the entry type over which this match expression will be able to iterate.- Returns:
- the entry type
-
determineExpected
public abstract java.lang.Object determineExpected(AbstractRuleMatchExpression rhsExpr, java.lang.Object rhsValue) throws VilException
Determines the expected value on the left side (represented by this object) based on the actual value for the corresponding right side.- Parameters:
rhsExpr- the (resolved) RHS expressionrhsValue- the RHS value- Returns:
- the expected LHS value (null denotes no expectation)
- Throws:
VilException- in case that determining the expected object fails
-
accept
public java.lang.Object accept(IExpressionVisitor visitor) throws VilException
Description copied from class:ExpressionVisits the expression.- Specified by:
acceptin classExpression- Parameters:
visitor- the visitor- Returns:
- the result of visiting this expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
accept
protected abstract java.lang.Object accept(IMatchVisitor visitor) throws VilException
Accepts the given visitor for visiting.- Parameters:
visitor- the match visitor used for visiting- Returns:
- the result of visiting (may be null)
- Throws:
VilException- in case of visiting / evaluation errors
-
contributesTo
public abstract boolean contributesTo(AbstractRuleMatchExpression expression)
Returns whether this rule match expression may contribute to the fulfillment ofexpression.- Parameters:
expression- the expression to be considered (typically a RHS expression, while this is a LHS expression)- Returns:
trueif this rule may contribute,falseelse
-
inferType
public TypeDescriptor<? extends Collection<? extends IArtifact>> inferType() throws VilException
Description copied from class:ExpressionInfers the type of this expression including the type of the contained sub-expressions.- Specified by:
inferTypein classExpression- Returns:
- the type of this expression
- Throws:
VilException- in case that inferring the type fails
-
evaluate
public abstract Collection<?> evaluate(IExpressionVisitor evaluator) throws VilException
Evaluates this expression. Some subtypes may define some kind of value resolution, e.g., for match expressions. This must be called before!- Parameters:
evaluator- the expression evaluator (in case that an actual expression must be evaluated as part of this evaluation).- Returns:
- the evaluation result
- Throws:
VilException- in case that evaluation fails
-
ensureType
protected static TypeDescriptor<? extends Collection<? extends IArtifact>> ensureType(TypeDescriptor<?> type) throws VilException
Ensures a collection type fortype.- Parameters:
type- the type to be checked and ensured- Returns:
- the collection type
- Throws:
VilException- in case thattypecannot be converted into a collection type
-
-