Class ModelCallExpression<V extends IMetaParameterDeclaration,M extends IResolvableModel<V,M>,O extends IResolvableOperation<V>>
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.expressions.Expression
-
- net.ssehub.easy.instantiation.core.model.expressions.AbstractCallExpression
-
- net.ssehub.easy.instantiation.core.model.common.ModelCallExpression<V,M,O>
-
- Type Parameters:
V- the actual type of variableM- the actual model typeO- the actual operation type
- All Implemented Interfaces:
IArgumentProvider
- Direct Known Subclasses:
InstantiateExpression,RuleCallExpression,TemplateCallExpression
public abstract class ModelCallExpression<V extends IMetaParameterDeclaration,M extends IResolvableModel<V,M>,O extends IResolvableOperation<V>> extends AbstractCallExpression implements IArgumentProvider
Represents the explicit execution of a model operation.- Author:
- Holger Eichelberger
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedModelCallExpression()Constructor for serialization.ModelCallExpression(M model, boolean isSuper, java.lang.String name, CallArgument... arguments)Creates a new model call expression.protectedModelCallExpression(M model, O resolved, CallArgument... arguments)Creates a new model call expression for a known operation.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description CallArgumentgetArgument(int index)Returns the specified argument.intgetArgumentsCount()Returns the number of arguments.protected java.lang.StringgetInvalidOperationMessage(IMetaOperation op)Returns the message to be returned in case of an invalid operation.MgetModel()Returns the owning model.protected abstract java.lang.Class<? extends O>getOperationClass()Returns the actual operation class, i.e., the class of the operation.OgetResolved()Returns the resolved operation.java.lang.StringgetVilSignature()Returns the VIL signature of the resolved operation.TypeDescriptor<?>inferType()Infers the type of this expression including the type of the contained sub-expressions.booleanisPlaceholder()Returns whether this operation is a placeholder, i.e., either the resolved operation is aplaceholder, its signature or its return type does contain aplaceholder type.booleanisSuper()Returns whether this call is a super script call.abstract booleanisVisible(M fromModel)Returns whether the resolved model operation is visible.(package private) voidsetModel(M model)Changes the owning model.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.AbstractCallExpression
dynamicDispatch, getName, getParameterType, getPrefix, getQualifiedName, getSignature, getVilSignature, isIteratingCollectionOperation, isOclCompliant, isPlaceholder, resolveOperation, resolveOperation, resolveResolvableOperation
-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.Expression
accept, replaceEmptyLine
-
-
-
-
Field Detail
-
resolved
protected O extends IResolvableOperation<V> resolved
-
model
private M extends IResolvableModel<V,M> model
-
arguments
private CallArgument[] arguments
-
isSuper
private boolean isSuper
-
-
Constructor Detail
-
ModelCallExpression
protected ModelCallExpression()
Constructor for serialization.
-
ModelCallExpression
public ModelCallExpression(M model, boolean isSuper, java.lang.String name, CallArgument... arguments) throws VilException
Creates a new model call expression.- Parameters:
model- the actual model to resolve the operation onisSuper- this is a super callname- the name of the operationarguments- the actual arguments- Throws:
VilException- in case of illegal (qualified) names
-
ModelCallExpression
protected ModelCallExpression(M model, O resolved, CallArgument... arguments) throws VilException
Creates a new model call expression for a known operation.- Parameters:
model- the actual modelresolvedbelongs toresolved- the resolved operationarguments- the actual arguments- Throws:
VilException- in case of illegal (qualified) names
-
-
Method Detail
-
isSuper
public boolean isSuper()
Returns whether this call is a super script call.- Returns:
trueif is a super script call,falseelse
-
getArgumentsCount
public int getArgumentsCount()
Returns the number of arguments.- Specified by:
getArgumentsCountin interfaceIArgumentProvider- Specified by:
getArgumentsCountin classAbstractCallExpression- Returns:
- the number of arguments
-
getArgument
public CallArgument getArgument(int index)
Returns the specified argument.- Specified by:
getArgumentin interfaceIArgumentProvider- Specified by:
getArgumentin classAbstractCallExpression- Parameters:
index- the 0-based index of the argument to return- Returns:
- the argument
- Throws:
java.lang.IndexOutOfBoundsException- in case thatindex < 0 || index >=getArgumentsCount()
-
getModel
public M getModel()
Returns the owning model.- Returns:
- the owning model
-
setModel
void setModel(M model)
Changes the owning model. Required, if a temporary model was used for resolution, e.g., in case of recursive calls.- Parameters:
model- the new model (null will be ignored)
-
getResolved
public O getResolved()
Returns the resolved operation.inferType()must be called before.- Returns:
- the resolved operation or null if
inferType()was not called before or the operation cannot be resolved
-
getOperationClass
protected abstract java.lang.Class<? extends O> getOperationClass()
Returns the actual operation class, i.e., the class of the operation.- Returns:
- the operation class
-
inferType
public TypeDescriptor<?> 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
-
getInvalidOperationMessage
protected java.lang.String getInvalidOperationMessage(IMetaOperation op)
Returns the message to be returned in case of an invalid operation.- Parameters:
op- the invalid operation- Returns:
- the related message
-
isPlaceholder
public boolean isPlaceholder()
Description copied from class:AbstractCallExpressionReturns whether this operation is a placeholder, i.e., either the resolved operation is aplaceholder, its signature or its return type does contain aplaceholder type.- Specified by:
isPlaceholderin classAbstractCallExpression- Returns:
trueif this operation is a placeholder and cannot be executed,falseelse
-
getVilSignature
public java.lang.String getVilSignature()
Description copied from class:AbstractCallExpressionReturns the VIL signature of the resolved operation.- Specified by:
getVilSignaturein classAbstractCallExpression- Returns:
- the VIL signature
-
isVisible
public abstract boolean isVisible(M fromModel)
Returns whether the resolved model operation is visible.- Parameters:
fromModel- the model issuing the call- Returns:
trueif the operation is visible,falseelse
-
-