Class 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
    • 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 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 Detail

      • 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​(java.lang.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
      • 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