Class RuleDescriptor
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.buildlangModel.RuleDescriptor
-
public class RuleDescriptor extends java.lang.ObjectDefines the complex parts of a rule. Instances of this class are just for creating rules. More or less direct access to the attributes is ok for this class.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private VariableDeclaration[]lhsMatchVariablesprivate RuleCallExpression[]lhsRuleCallsprivate AbstractRuleMatchExpression[]lhsRuleMatchesprivate VariableDeclaration[]lhsVariablesstatic java.lang.StringMATCH_VAR_POSTFIXprivate TypeDescriptor<?>returnTypeprivate VariableDeclaration[]rhsMatchVariablesprivate RuleCallExpression[]rhsRuleCallsprivate AbstractRuleMatchExpression[]rhsRuleMatchesprivate VariableDeclaration[]rhsVariables
-
Constructor Summary
Constructors Constructor Description RuleDescriptor()Creates an empty descriptor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description VariableDeclaration[]getMatchVariables(Rule.Side side)Returns the match variables on the given side.TypeDescriptor<?>getReturnType()Returns the return type of this rule descriptor.intgetRuleCallCount(Rule.Side side)Returns the number of rule calls on the specified side.RuleCallExpression[]getRuleCalls(Rule.Side side)Returns the rule calls on the specified side.intgetRuleMatchCount(Rule.Side side)Returns the number of match expressions on the specified side.AbstractRuleMatchExpression[]getRuleMatches(Rule.Side side)Returns the rule match conditions on the specified side.VariableDeclaration[]getVariables(Rule.Side side)Returns the variables on the given side.voidregisterVariables(Resolver resolver)Registers the LHS/RHS variables inresolverif applicable.private voidregisterVariables(Rule.Side side, Resolver res, java.util.Map<java.lang.String,java.lang.Integer> names)Registers the variables inresolverif applicable.voidsetReturnType(TypeDescriptor<?> returnType)Defines the return type of this rule descriptor.voidsetRuleExpressions(Rule.Side side, java.util.List<Expression> conditions)Defines the rule conditions on the given side.private static VariableDeclaration[]toArray(java.util.List<VariableDeclaration> vars)Turns a list of variable declarations into an array and considers null as input.
-
-
-
Field Detail
-
MATCH_VAR_POSTFIX
public static final java.lang.String MATCH_VAR_POSTFIX
- See Also:
- Constant Field Values
-
lhsRuleMatches
private AbstractRuleMatchExpression[] lhsRuleMatches
-
lhsRuleCalls
private RuleCallExpression[] lhsRuleCalls
-
rhsRuleMatches
private AbstractRuleMatchExpression[] rhsRuleMatches
-
rhsRuleCalls
private RuleCallExpression[] rhsRuleCalls
-
lhsVariables
private VariableDeclaration[] lhsVariables
-
rhsVariables
private VariableDeclaration[] rhsVariables
-
lhsMatchVariables
private VariableDeclaration[] lhsMatchVariables
-
rhsMatchVariables
private VariableDeclaration[] rhsMatchVariables
-
returnType
private TypeDescriptor<?> returnType
-
-
Method Detail
-
setRuleExpressions
public void setRuleExpressions(Rule.Side side, java.util.List<Expression> conditions) throws RuleDescriptorException
Defines the rule conditions on the given side. Rule calls and rule condition expressions are separated in here.- Parameters:
side- the side to return the calls for (LHS, RHS)conditions- the conditions (may be null if there are none)- Throws:
RuleDescriptorException- in case that the given expressions cannot be applied (in the given sequence)
-
getRuleMatches
public AbstractRuleMatchExpression[] getRuleMatches(Rule.Side side)
Returns the rule match conditions on the specified side.- Parameters:
side- the side to return the calls for (LHS, RHS)- Returns:
- the rule match conditions (may be null)
-
getRuleMatchCount
public int getRuleMatchCount(Rule.Side side)
Returns the number of match expressions on the specified side.- Parameters:
side- the side to return the calls for (LHS, RHS)- Returns:
- the number of match expressions
-
getRuleCalls
public RuleCallExpression[] getRuleCalls(Rule.Side side)
Returns the rule calls on the specified side.- Parameters:
side- the side to return the calls for (LHS, RHS)- Returns:
- the rule calls (may be null)
-
getRuleCallCount
public int getRuleCallCount(Rule.Side side)
Returns the number of rule calls on the specified side.- Parameters:
side- the side to return the calls for (LHS, RHS)- Returns:
- the number of rule calls
-
registerVariables
public void registerVariables(Resolver resolver) throws VilException
Registers the LHS/RHS variables inresolverif applicable.- Parameters:
resolver- the resolver instance- Throws:
VilException- in case that resolving one of the expressions fails
-
registerVariables
private void registerVariables(Rule.Side side, Resolver res, java.util.Map<java.lang.String,java.lang.Integer> names) throws VilException
Registers the variables inresolverif applicable.- Parameters:
side- the side to register variables for (LHS, RHS)res- the resolver instancenames- a mapping of names and a related counter how often the variable name (without number) has been used so far in this rule head- Throws:
VilException- in case that resolving one of the expressions fails
-
toArray
private static VariableDeclaration[] toArray(java.util.List<VariableDeclaration> vars)
Turns a list of variable declarations into an array and considers null as input.- Parameters:
vars- the list of variables to be turned into an array- Returns:
- the array, null if the input is empty or null
-
getVariables
public VariableDeclaration[] getVariables(Rule.Side side)
Returns the variables on the given side.- Parameters:
side- the side to return the variables for (LHS, RHS)- Returns:
- the LHS variables or null if there is none
-
getMatchVariables
public VariableDeclaration[] getMatchVariables(Rule.Side side)
Returns the match variables on the given side.- Parameters:
side- the side to return the match variables for (LHS, RHS)- Returns:
- the LHS variables or null if there is none
-
setReturnType
public void setReturnType(TypeDescriptor<?> returnType)
Defines the return type of this rule descriptor.- Parameters:
returnType- the return type (may be null if undefined, use default instead)
-
getReturnType
public TypeDescriptor<?> getReturnType()
Returns the return type of this rule descriptor.- Returns:
- the return type (may be null if undefined, use default instead)
-
-