Class CustomOperation
java.lang.Object
net.ssehub.easy.varModel.model.datatypes.Operation
net.ssehub.easy.varModel.model.datatypes.CustomOperation
- Direct Known Subclasses:
CustomDynamicOperation
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
FieldsModifier and TypeFieldDescriptionprivate String[]private ConstraintSyntaxTreeprivate Map<String, DecisionVariableDeclaration> private DecisionVariableDeclaration[] -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for serialization.CustomOperation(IDatatype returns, String methodname, IDatatype operand, ConstraintSyntaxTree function, DecisionVariableDeclaration[] parameters) Operation Constructor. -
Method Summary
Modifier and TypeMethodDescriptiongetAnnotation(int index) Returns the specified annotation.intReturns the number of declared annotations.Returns the function expression calculated by this operation.getParameter(String name) Returns the specified named parameter.intReturns the number of parameters of this operation.getParameterDeclaration(int index) Returns the parameter at positionindex.private static IDatatype[]Returns the datatypes of the parameter declarations.intReturns the number of required parameters.booleanhasAnnotation(String annotation) Returns whether the operation ownsannotationirrespective of upper/lowercase characters.static booleanhasAnnotation(String[] annotations, String annotation) Returns whetherannotationscontainsannotationirrespective of upper/lowercase characters.protected booleanReturns whether this operation shall be registered as a global operation.voidsetAnnotations(List<String> annotations) Defines the operation annotations.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 Details
-
function
-
parameters
-
namedParameters
-
annotations
-
-
Constructor Details
-
CustomOperation
CustomOperation()Constructor for serialization. -
CustomOperation
public CustomOperation(IDatatype returns, 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 Details
-
setFunction
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
Returns the datatypes of the parameter declarations.- Parameters:
decl- the parameter declarations (may be null)- Returns:
- the datatypes (null if
declis null)
-
getFunction
Description copied from class:OperationReturns the function expression calculated by this operation.- Overrides:
getFunctionin classOperation- Returns:
- the function operation (always null)
-
getParameterDeclaration
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
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
-
setAnnotations
Defines the operation annotations.- Parameters:
annotations- the annotations
-
getAnnotationCount
public int getAnnotationCount()Returns the number of declared annotations.- Returns:
- the number of declared annotations
-
getAnnotation
Returns the specified annotation.- Parameters:
index- the 0-based index of the annotation- Returns:
- the specified annotation
- Throws:
IndexOutOfBoundsException- if no annotations are defined or if the index is not in[0;getAnnotationCount())
-
hasAnnotation
Returns whether the operation ownsannotationirrespective of upper/lowercase characters.- Parameters:
annotation- the annotation to search- Returns:
truefor found,trueelse
-
hasAnnotation
Returns whetherannotationscontainsannotationirrespective of upper/lowercase characters.- Parameters:
annotations- the annotations to search within (may be null)annotation- the annotation to search- Returns:
truefor found,trueelse
-
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
-