Class FormulaFunctions

java.lang.Object
org.yamcs.studio.data.formula.FormulaFunctions

public class FormulaFunctions extends Object
A set of utility methods for formula functions.
  • Constructor Details

    • FormulaFunctions

      public FormulaFunctions()
  • Method Details

    • matchArgumentTypes

      public static boolean matchArgumentTypes(List<Object> arguments, FormulaFunction function)
      Check whether the function will accept the given list of values as arguments.
      Parameters:
      arguments - the possible values
      function - a function
      Returns:
      true if the function can accept the given arguments
    • matchArgumentTypes

      public static boolean matchArgumentTypes(List<Object> arguments, FormulaFunction function, boolean allowNull)
      Checks whether the function will accept the given arguments.
      Parameters:
      arguments - the arguments
      function - a function
      allowNull - whether the function should allow null arguments
      Returns:
      true if the function can accept the given arguments
    • matchArgumentCount

      public static boolean matchArgumentCount(int nArguments, FormulaFunction function)
      Check whether the function will accept the given number of arguments.
      Parameters:
      nArguments - the number of arguments
      function - a function
      Returns:
      true if the function can accept the given number of arguments
    • findFirstMatch

      public static FormulaFunction findFirstMatch(List<Object> arguments, Collection<FormulaFunction> formulaFunctions)
      Finds the first function that can accept the given values as arguments.
      Parameters:
      arguments - the possible values
      formulaFunctions - a collection of functions
      Returns:
      the first function that accepts the give arguments
    • findArgTypeMatch

      public static Collection<FormulaFunction> findArgTypeMatch(List<Class<?>> argTypes, Collection<FormulaFunction> formulaFunctions)
      Finds the functions that match the given types as arguments.
      Parameters:
      argTypes - the possible types
      formulaFunctions - a collection of functions
      Returns:
      the first function that accepts the give arguments
    • formatSignature

      public static String formatSignature(FormulaFunction function)
      Returns a string representation of the function that will include the function name, argument types, argument names and the result type.
      Parameters:
      function - a function
      Returns:
      string representation
    • format

      public static String format(String function, List<String> args)
      Given the function name and a string representation of the arguments, returns the properly formatted string representation of the whole expression.
      Parameters:
      function - the function name
      args - the arguments
      Returns:
      the expression text representation