Class Function


  • public final class Function
    extends java.lang.Object
    The Function class describes a custom function that extends the functionality of a solver. A function represents an operation described in terms of expressions that use existing solver operations.
    • Constructor Summary

      Constructors 
      Constructor Description
      Function​(java.lang.Enum<?> id, DataType returnType, Node body, Variable... parameters)
      Creates a function with a variable number of parameters.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Node getBody()
      Returns the body of the function (underlying expression).
      java.lang.Enum<?> getId()
      Returns the identifier of the operation associated with the function.
      Variable getParameter​(int index)
      Returns function parameters by their index.
      int getParameterCount()
      Returns the parameter count.
      DataType getReturnType()
      Returns the function return type.
      java.lang.String getUniqueName()
      Returns a unique name for the function.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Function

        public Function​(java.lang.Enum<?> id,
                        DataType returnType,
                        Node body,
                        Variable... parameters)
        Creates a function with a variable number of parameters.
        Parameters:
        id - The identifier of the operator the function is associated with.
        returnType - The function return type.
        body - The body of the function (underlying expression).
        parameters - An variable-length list of parameters.
        Throws:
        java.lang.IllegalArgumentException - if any of the parameters is null.
    • Method Detail

      • getId

        public java.lang.Enum<?> getId()
        Returns the identifier of the operation associated with the function.
        Returns:
        Operation identifier for the function.
      • getUniqueName

        public java.lang.String getUniqueName()
        Returns a unique name for the function. The name is based on the function's identifier, return value type and parameter types. It helps distinguish overloaded functions that use the same identifier but have different parameter type and return types.
        Returns:
        Unique name of the function.
      • getReturnType

        public DataType getReturnType()
        Returns the function return type.
        Returns:
        The function return type.
      • getBody

        public Node getBody()
        Returns the body of the function (underlying expression).
        Returns:
        The syntax element describing the body of the function.
      • getParameterCount

        public int getParameterCount()
        Returns the parameter count.
        Returns:
        The number of parameters.
      • getParameter

        public Variable getParameter​(int index)
        Returns function parameters by their index.
        Parameters:
        index - The index of the needed parameter.
        Returns:
        A function parameter.
        Throws:
        java.lang.IndexOutOfBoundsException - if the parameter index is out of bounds of the parameter array.