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
  • Field Details

  • 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 operation
      methodname - name of the operation
      operand - the data type the operation is defined for (shall be a project)
      function - the operation calculated by this operation
      parameters - list of parameters for operation
  • Method Details

    • setFunction

      public void setFunction(ConstraintSyntaxTree function) throws CSTSemanticException
      Changes the function determining the implementation of this custom operation. function may 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 decl is null)
    • getFunction

      public ConstraintSyntaxTree getFunction()
      Description copied from class: Operation
      Returns the function expression calculated by this operation.
      Overrides:
      getFunction in class Operation
      Returns:
      the function operation (always null)
    • getParameterDeclaration

      public DecisionVariableDeclaration getParameterDeclaration(int index)
      Description copied from class: Operation
      Returns the parameter at position index.
      Overrides:
      getParameterDeclaration in class Operation
      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(String name)
      Description copied from class: Operation
      Returns the specified named parameter.
      Overrides:
      getParameter in class Operation
      Parameters:
      name - the name of the parameter
      Returns:
      the named parameter declaration (may be null)
    • getParameterCount

      public int getParameterCount()
      Description copied from class: Operation
      Returns the number of parameters of this operation.
      Overrides:
      getParameterCount in class Operation
      Returns:
      the number of parameters
    • getRequiredParameterCount

      public int getRequiredParameterCount()
      Description copied from class: Operation
      Returns the number of required parameters.
      Overrides:
      getRequiredParameterCount in class Operation
      Returns:
      the number of required parameters
    • setAnnotations

      public void setAnnotations(List<String> annotations)
      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

      public String getAnnotation(int index)
      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

      public boolean hasAnnotation(String annotation)
      Returns whether the operation owns annotation irrespective of upper/lowercase characters.
      Parameters:
      annotation - the annotation to search
      Returns:
      true for found, true else
    • hasAnnotation

      public static boolean hasAnnotation(String[] annotations, String annotation)
      Returns whether annotations contains annotation irrespective of upper/lowercase characters.
      Parameters:
      annotations - the annotations to search within (may be null)
      annotation - the annotation to search
      Returns:
      true for found, true else
    • registerAsOperation

      protected boolean registerAsOperation()
      Description copied from class: Operation
      Returns whether this operation shall be registered as a global operation.
      Overrides:
      registerAsOperation in class Operation
      Returns:
      true if it should be registered, false else