Class VtlRule
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.buildlangModel.ProjectElement
-
- net.ssehub.easy.instantiation.core.model.buildlangModel.RuleBlock
-
- net.ssehub.easy.instantiation.core.model.buildlangModel.AbstractRule
-
- net.ssehub.easy.instantiation.core.model.buildlangModel.VtlRule
-
- All Implemented Interfaces:
IBuildlangElement,IRuleBlock,ILanguageElement,IParameterizable<VariableDeclaration>,IResolvableOperation<VariableDeclaration>,IMetaOperation,IStringValueProvider
public class VtlRule extends AbstractRule
Maps a VTL rule into VIL.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.IMetaOperation
IMetaOperation.CompatibilityResult
-
Nested classes/interfaces inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider
IStringValueProvider.StringComparator
-
-
Field Summary
Fields Modifier and Type Field Description private Defdefprivate java.util.Map<java.lang.String,VariableDeclaration>namedParamsprivate VariableDeclaration[]parameterprivate Scriptparent
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectaccept(IVisitor visitor)Accepts the visitor for visiting.booleanacceptsNamedParameters()Returns whether the operation accepts named parameters.voidappendCallTo(AbstractRule target, boolean qualifiedCall)Appends a call totargetto the rule body.IMetaTypegetDeclaringType()Returns the declaring type.DefgetDef()Returns the def stored in this instance.java.lang.StringgetJavaSignature()Returns the java-like signature of this operation.VariableDeclarationgetParameter(int index)Get the parameter of this rule at the specified index.VariableDeclarationgetParameter(java.lang.String name)Returns a named parameter declaration.intgetParameterCount()Get the number of parameters of this rule.IMetaTypegetParameterType(int index)Returns the specified parameter type.ScriptgetParent()Returns the parent script this rule is member of.intgetRequiredParameterCount()Returns the number of required parameters, i.e., non-default and non-named parameters.TypeDescriptor<?>getReturnType()Returns the return type of this operation.RuleCallExpressiongetRuleCall(Rule.Side side, int index)Get the rule call on the given side of this rule at the specified index.intgetRuleCallCount(Rule.Side side)Get the number of rule calls on the given side of this rule.AbstractRuleMatchExpressiongetRuleCondition(Rule.Side side, int index)Get the match conditions of this rule on the given side at the specified index.intgetRuleConditionCount(Rule.Side side)Get the number of match conditions on the given side of this rule.java.lang.StringgetSignature()Returns the signature of the method (in terms of VIL types where possible).java.lang.StringgetStringValue(IStringValueProvider.StringComparator comparator)Returns the string value of this object.booleanhasCondition(Rule.Side side)Returns whether the specified side has either rule calls or a matching condition.java.lang.Objectinvoke(java.lang.Object... args)Invokes the specified operation.IMetaOperation.CompatibilityResultisCompatible(java.lang.Class<?> retType, java.lang.Object... params)Returns whether the operation represented by this instance is compatible to the given return type and parameters.booleanisFirstParameterOperand()Returns whether the first parameter is the operand.booleanisPlaceholder()Returns whether this operation is valid or whether it is a placeholder operation in case that the original operation cannot be resolved but the script shall remain executable.booleanisProtected()Returns whether a rule is declared as protected regarding its visibility.booleanisStatic()Returns whether this operation is static.booleanisVirtual()Returns whether this block is a real block or consists just of a block element without brackets.booleanreturnActualValue()Returns whether this body shall return an actual value (function) or a rule execution result.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.buildlangModel.AbstractRule
isConstructor
-
Methods inherited from class net.ssehub.easy.instantiation.core.model.buildlangModel.RuleBlock
addBodyElement, addBodyElement, append, getBodyElement, getBodyElementCount, setBody, setParent
-
Methods inherited from class net.ssehub.easy.instantiation.core.model.buildlangModel.ProjectElement
getName
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.IMetaOperation
getName
-
-
-
-
Field Detail
-
parent
private Script parent
-
def
private Def def
-
parameter
private VariableDeclaration[] parameter
-
namedParams
private java.util.Map<java.lang.String,VariableDeclaration> namedParams
-
-
Method Detail
-
getReturnType
public TypeDescriptor<?> getReturnType()
Description copied from interface:IResolvableOperationReturns the return type of this operation.- Returns:
- the return type
-
getParameterCount
public int getParameterCount()
Description copied from interface:IParameterizableGet the number of parameters of this rule.- Returns:
- The number of parameters of this rule.
-
getParameter
public VariableDeclaration getParameter(int index)
Description copied from interface:IParameterizableGet the parameter of this rule at the specified index.- Parameters:
index- The 0-based index of the rule parameter to be returned.- Returns:
- The rule parameter at the given index.
-
getRequiredParameterCount
public int getRequiredParameterCount()
Description copied from interface:IParameterizableReturns the number of required parameters, i.e., non-default and non-named parameters.- Returns:
- the number of required parameters
-
getParameter
public VariableDeclaration getParameter(java.lang.String name)
Description copied from interface:IParameterizableReturns a named parameter declaration.- Parameters:
name- the name of the parameter- Returns:
- the declaration or null if there is none
-
isStatic
public boolean isStatic()
Description copied from interface:IMetaOperationReturns whether this operation is static.- Returns:
trueif it is static,falseelse
-
isFirstParameterOperand
public boolean isFirstParameterOperand()
Description copied from interface:IMetaOperationReturns whether the first parameter is the operand.- Returns:
trueif the first parameter is the operand,falseelse
-
getParameterType
public IMetaType getParameterType(int index)
Description copied from interface:IMetaOperationReturns the specified parameter type.- Parameters:
index- the index of the parameter to return- Returns:
- the specified parameter type
-
getJavaSignature
public java.lang.String getJavaSignature()
Description copied from interface:IMetaOperationReturns the java-like signature of this operation.- Returns:
- the java-like Java signature of this operation
-
getSignature
public java.lang.String getSignature()
Description copied from interface:IMetaOperationReturns the signature of the method (in terms of VIL types where possible).- Returns:
- the signature of the method
-
acceptsNamedParameters
public boolean acceptsNamedParameters()
Description copied from interface:IMetaOperationReturns whether the operation accepts named parameters.- Returns:
trueif it accepts named parameters,falseelse
-
getDeclaringType
public IMetaType getDeclaringType()
Description copied from interface:IMetaOperationReturns the declaring type.- Returns:
- the declaring type (may be null in case of a wrapped external Java method)
-
isPlaceholder
public boolean isPlaceholder()
Description copied from interface:IMetaOperationReturns whether this operation is valid or whether it is a placeholder operation in case that the original operation cannot be resolved but the script shall remain executable.- Returns:
trueif this operation is a placeholder,falseelse
-
isCompatible
public IMetaOperation.CompatibilityResult isCompatible(java.lang.Class<?> retType, java.lang.Object... params)
Description copied from interface:IMetaOperationReturns whether the operation represented by this instance is compatible to the given return type and parameters. This method does not consider possible unnamed parameter rather than the underlying Java parameter.- Parameters:
retType- the return type (may be null in order to ignore this parameter)params- the parameters (may be null if there are none, may be classes)- Returns:
- an instance of
IMetaOperation.CompatibilityResultdenoting the actual compatibility level
-
invoke
public java.lang.Object invoke(java.lang.Object... args) throws VilExceptionDescription copied from interface:IMetaOperationInvokes the specified operation. This method does not consider possible unnamed parameter rather than the underlying Java parameter. In case ofIMetaOperation.acceptsNamedParameters()the caller must ensure that the last parameter is amap<String, Object>containing the named parameters.- Parameters:
args- the arguments, in case of non-static operations the first argument must be the object to execute on- Returns:
- the result of the execution
- Throws:
VilException- if the invocation fails- See Also:
IMetaOperation.isCompatible(java.lang.Class<?>, java.lang.Object...)
-
getStringValue
public java.lang.String getStringValue(IStringValueProvider.StringComparator comparator)
Description copied from interface:IStringValueProviderReturns the string value of this object.- Parameters:
comparator- if the sequence of elements, e.g., in case of collections, shall be ordered according to the comparator, null if the original sequence shall be returned- Returns:
- the string value
-
isVirtual
public boolean isVirtual()
Description copied from interface:IRuleBlockReturns whether this block is a real block or consists just of a block element without brackets.- Returns:
trueif this block is virtual,falseelse
-
returnActualValue
public boolean returnActualValue()
Description copied from interface:IRuleBlockReturns whether this body shall return an actual value (function) or a rule execution result.- Returns:
truein case of an actual value,falseelse
-
accept
public java.lang.Object accept(IVisitor visitor) throws VilException
Description copied from interface:IBuildlangElementAccepts the visitor for visiting.- Parameters:
visitor- the visitor to be used- Returns:
- the result of visiting this instance (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
getRuleConditionCount
public int getRuleConditionCount(Rule.Side side)
Description copied from class:AbstractRuleGet the number of match conditions on the given side of this rule.- Specified by:
getRuleConditionCountin classAbstractRule- Parameters:
side- the side (LHS, RHS)- Returns:
- The number of preconditions (match conditions) of this rule.
-
getRuleCondition
public AbstractRuleMatchExpression getRuleCondition(Rule.Side side, int index)
Description copied from class:AbstractRuleGet the match conditions of this rule on the given side at the specified index.- Specified by:
getRuleConditionin classAbstractRule- Parameters:
side- the side (LHS, RHS)index- The 0-based index of the match condition to be returned.- Returns:
- The match condition at the given index.
-
hasCondition
public boolean hasCondition(Rule.Side side)
Description copied from class:AbstractRuleReturns whether the specified side has either rule calls or a matching condition.- Specified by:
hasConditionin classAbstractRule- Parameters:
side- the side (LHS, RHS)- Returns:
- whether the specified side has cinditions at all
-
getRuleCallCount
public int getRuleCallCount(Rule.Side side)
Description copied from class:AbstractRuleGet the number of rule calls on the given side of this rule.- Specified by:
getRuleCallCountin classAbstractRule- Parameters:
side- the side (LHS, RHS)- Returns:
- The number of postconditions of this rule.
-
getRuleCall
public RuleCallExpression getRuleCall(Rule.Side side, int index)
Description copied from class:AbstractRuleGet the rule call on the given side of this rule at the specified index.- Specified by:
getRuleCallin classAbstractRule- Parameters:
side- the side (LHS, RHS)index- The 0-based index of the rule element to be returned.- Returns:
- The rule element at the given index.
-
isProtected
public boolean isProtected()
Description copied from class:AbstractRuleReturns whether a rule is declared as protected regarding its visibility.- Specified by:
isProtectedin classAbstractRule- Returns:
trueif it is protected,falseelse
-
appendCallTo
public void appendCallTo(AbstractRule target, boolean qualifiedCall) throws VilException
Appends a call totargetto the rule body. Currently, this method considers parameters only in the sequence of the parameters of this rule.- Specified by:
appendCallToin classAbstractRule- Parameters:
target- the rule to append the call toqualifiedCall- insert a qualified call iftrue, an unqualified call iffalse- Throws:
VilException- in case that creating / resolving the rule call fails
-
getParent
public Script getParent()
Description copied from class:AbstractRuleReturns the parent script this rule is member of.- Specified by:
getParentin interfaceILanguageElement- Specified by:
getParentin classAbstractRule- Returns:
- the parent
-
getDef
public Def getDef()
Returns the def stored in this instance.- Returns:
- the def
-
-