Interface Function

All Known Implementing Classes:
AbstractFunction

public interface Function
The basic description of a Function.

Cytoscape Backwards Compatibility (SPI Interface): We expect that this interface will be implemented. Therefore to maintain backwards compatibility this interface will only be modified for major version updates.

Module: equations-api

To use this in your app, include the following dependency in your POM:

<dependency>
    <groupId>org.cytoscape</groupId>
    <artifactId>equations-api</artifactId>
</dependency>
  • Method Details

    • getName

      String getName()
      Used to parse the function string. This name is treated in a case-insensitive manner!
      Returns:
      the name by which you must call the function when used in an attribute equation.
    • getFunctionSummary

      String getFunctionSummary()
      Used to provide help for users. Unlike getUsageDescription(), this is an informal English description, like "Calculates the sine of its argument."
      Returns:
      a description of what this function does
    • getUsageDescription

      String getUsageDescription()
      Used to provide help for users. Unlike getFunctionSummary(), this describes how to call this function, like "Call with SIN(number)."
      Returns:
      a description of how to use this function
    • getReturnType

      Class<?> getReturnType()
      Returns:
      the static return type of this function, Object.class, Double.cLass, String.class, or Boolean.class. If the static return type is Object.class, the dynamic return type will be one of Double.cLass, String.class, or Boolean.class and will depend on the arguments passed to the function! Note, this is used by external tools used to filter a list of functions based on what a valid return type might be. In Cytoscape it is used in the attribute browser's formula builder.
    • validateArgTypes

      Class<?> validateArgTypes(Class<?>[] argTypes)
      Returns:
      the return type for this function (Double.cLass, String.class, or Boolean.class) or null if the args passed in had the wrong arity or a type mismatch Note that this is different from getReturnType() in that it will never return the wildcard Object.class. It is used by the parser which knows the actual type of the arguments in any given call to this function.
    • evaluateFunction

      Object evaluateFunction(Object[] args) throws FunctionError
      Used to invoke this function.
      Parameters:
      args - the function arguments which must correspond in type and number to what getParameterTypes() returns.
      Returns:
      the result of the function evaluation. The actual type of the returned object will be what getReturnType() returns.
      Throws:
      FunctionError
      ArithmeticException - thrown if a numeric error, e.g. a division by zero occurred.
      IllegalArgumentException - thrown for any error that is not a numeric error, for example if a function only accepts positive numbers and a negative number was passed in.
    • getPossibleArgTypes

      List<Class<?>> getPossibleArgTypes(Class<?>[] leadingArgs)
      Used with the equation builder.
      Parameters:
      leadingArgs - the types of the arguments that have already been selected by the user.
      Returns:
      the set of arguments (must be a collection of String.class, Long.class, Double.class, Boolean.class and List.class) that are candidates for the next argument. A null return indicates that no further arguments are valid. Please note that if the returned set contains a null, this indicates an optional additional argument.
    • getArgumentDescriptors

      default List<ArgDescriptor> getArgumentDescriptors()
      Returns the usage descriptions for the function's arguments. Used to provide help for users. This is an optional operation, may return null.
      Since:
      3.9
    • getCategoryName

      default String getCategoryName()
      Used to provide help for users. Returns the category for a function. For example numeric functions such as SIN, COS and SQRT could all return "Numeric" as their category. This is an optional operation, may return null.
      Since:
      3.9