Class CustomOperation
- java.lang.Object
-
- net.ssehub.easy.varModel.model.datatypes.Operation
-
- net.ssehub.easy.varModel.model.datatypes.CustomOperation
-
- Direct Known Subclasses:
CustomDynamicOperation
public class CustomOperation extends Operation
Represents a custom operation as defined in the IVML model. Not that currently custom operations are not generic and that the operand needs to be the holder of the custom operation, i.e. the project in order to support empty parameter lists.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.ssehub.easy.varModel.model.datatypes.Operation
Operation.FormattingHint, Operation.NestingMode, Operation.ReturnTypeMode
-
-
Field Summary
Fields Modifier and Type Field Description private ConstraintSyntaxTreefunctionprivate java.util.Map<java.lang.String,DecisionVariableDeclaration>namedParametersprivate DecisionVariableDeclaration[]parameters
-
Constructor Summary
Constructors Constructor Description CustomOperation()Constructor for serialization.CustomOperation(IDatatype returns, java.lang.String methodname, IDatatype operand, ConstraintSyntaxTree function, DecisionVariableDeclaration[] parameters)Operation Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ConstraintSyntaxTreegetFunction()Returns the function expression calculated by this operation.DecisionVariableDeclarationgetParameter(java.lang.String name)Returns the specified named parameter.intgetParameterCount()Returns the number of parameters of this operation.DecisionVariableDeclarationgetParameterDeclaration(int index)Returns the parameter at positionindex.private static IDatatype[]getParameterTypes(DecisionVariableDeclaration[] decl)Returns the datatypes of the parameter declarations.intgetRequiredParameterCount()Returns the number of required parameters.protected booleanregisterAsOperation()Returns whether this operation shall be registered as a global operation.voidsetFunction(ConstraintSyntaxTree function)Changes the function determining the implementation of this custom operation.-
Methods inherited from class net.ssehub.easy.varModel.model.datatypes.Operation
acceptsNull, createCollectionReturnType, createInfixOperator, createPostfixOperator, createPrefixOperator, getActualReturnType, getAlias, getFormattingHint, getName, getNestingMode, getOperand, getOperation, getOperationsCount, getParameterDefaultValue, getParameterType, getReturns, getReturnTypeMode, getSignature, isContainerOperation, isFallback, isStatic, markAsAcceptsNull, markAsAliasOf, markAsAssignableParameterOperation, markAsContainerOperation, markAsFallback, markAsFlatteningContainerOperation, markAsNestingContainerOperation, markByFormattingHint, requiresAssignableParameter
-
-
-
-
Field Detail
-
function
private ConstraintSyntaxTree function
-
parameters
private DecisionVariableDeclaration[] parameters
-
namedParameters
private java.util.Map<java.lang.String,DecisionVariableDeclaration> namedParameters
-
-
Constructor Detail
-
CustomOperation
CustomOperation()
Constructor for serialization.
-
CustomOperation
public CustomOperation(IDatatype returns, java.lang.String methodname, IDatatype operand, ConstraintSyntaxTree function, DecisionVariableDeclaration[] parameters)
Operation Constructor.- Parameters:
returns- result type of the operationmethodname- name of the operationoperand- the data type the operation is defined for (shall be a project)function- the operation calculated by this operationparameters- list of parameters for operation
-
-
Method Detail
-
setFunction
public void setFunction(ConstraintSyntaxTree function) throws CSTSemanticException
Changes the function determining the implementation of this custom operation.functionmay refer to the parameters of this custom operation.- Parameters:
function- the new function- Throws:
CSTSemanticException- in case that the return type does not comply to the function
-
getParameterTypes
private static IDatatype[] getParameterTypes(DecisionVariableDeclaration[] decl)
Returns the datatypes of the parameter declarations.- Parameters:
decl- the parameter declarations (may be null)- Returns:
- the datatypes (null if
declis null)
-
getFunction
public ConstraintSyntaxTree getFunction()
Description copied from class:OperationReturns the function expression calculated by this operation.- Overrides:
getFunctionin classOperation- Returns:
- the function operation (always null)
-
getParameterDeclaration
public DecisionVariableDeclaration getParameterDeclaration(int index)
Description copied from class:OperationReturns the parameter at positionindex.- Overrides:
getParameterDeclarationin classOperation- Parameters:
index- a 0-based index denoting the parameter to be returned- Returns:
- the specified parameter (may be null if there is no formal declaration
-
getParameter
public DecisionVariableDeclaration getParameter(java.lang.String name)
Description copied from class:OperationReturns the specified named parameter.- Overrides:
getParameterin classOperation- Parameters:
name- the name of the parameter- Returns:
- the named parameter declaration (may be null)
-
getParameterCount
public int getParameterCount()
Description copied from class:OperationReturns the number of parameters of this operation.- Overrides:
getParameterCountin classOperation- Returns:
- the number of parameters
-
getRequiredParameterCount
public int getRequiredParameterCount()
Description copied from class:OperationReturns the number of required parameters.- Overrides:
getRequiredParameterCountin classOperation- Returns:
- the number of required parameters
-
registerAsOperation
protected boolean registerAsOperation()
Description copied from class:OperationReturns whether this operation shall be registered as a global operation.- Overrides:
registerAsOperationin classOperation- Returns:
trueif it should be registered,falseelse
-
-