Class Function

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    FunctionExpresion

    public abstract class Function
    extends java.lang.Object
    implements java.io.Serializable
    A class representing a Function which can be used in an expression
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      Function​(java.lang.String name)
      Create a new Function with a given name that takes a single argument
      Function​(java.lang.String name, int numArguments)
      Create a new Function with a given name and number of arguments
      Function​(java.lang.String name, int numArguments, boolean deterministic)
      Create a new Function with a given name and number of arguments
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract double apply​(double... args)
      Method that does the actual calculation of the function value given the arguments
      java.lang.String getName()
      Get the name of the Function
      int getNumArguments()
      Get the number of arguments for this function
      boolean isDeterministic()
      Tells if a function is deterministic, in this scenario basically applies to functions that are not supposed to be simplified.
      static boolean isValidFunctionName​(java.lang.String name)
      Tells if a function name is valid in the context of the expression.
      • 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.String name,
                        int numArguments,
                        boolean deterministic)
        Create a new Function with a given name and number of arguments
        Parameters:
        name - the name of the Function
        numArguments - the number of arguments the function takes
        deterministic - true if the function is deterministic (i.e. can be simplified) false otherwise
      • Function

        public Function​(java.lang.String name,
                        int numArguments)
        Create a new Function with a given name and number of arguments
        Parameters:
        name - the name of the Function
        numArguments - the number of arguments the function takes
      • Function

        public Function​(java.lang.String name)
        Create a new Function with a given name that takes a single argument
        Parameters:
        name - the name of the Function
    • Method Detail

      • isDeterministic

        public boolean isDeterministic()
        Tells if a function is deterministic, in this scenario basically applies to functions that are not supposed to be simplified.
        Returns:
        true if the function is to be simplified (deterministic) and false otherwise
      • getName

        public java.lang.String getName()
        Get the name of the Function
        Returns:
        the name
      • getNumArguments

        public int getNumArguments()
        Get the number of arguments for this function
        Returns:
        the number of arguments
      • apply

        public abstract double apply​(double... args)
        Method that does the actual calculation of the function value given the arguments
        Parameters:
        args - the set of arguments used for calculating the function
        Returns:
        the result of the function evaluation
      • isValidFunctionName

        public static boolean isValidFunctionName​(java.lang.String name)
        Tells if a function name is valid in the context of the expression. This means that it's not null or empty and it only contains ASCII chars, _ or digits.
        Parameters:
        name - name to test
        Returns:
        true if the function name can be used and false otherwise