Package org.yamcs.studio.data.formula
Class FormulaFunctions
java.lang.Object
org.yamcs.studio.data.formula.FormulaFunctions
A set of utility methods for formula functions.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<FormulaFunction>
findArgTypeMatch
(List<Class<?>> argTypes, Collection<FormulaFunction> formulaFunctions) Finds the functions that match the given types as arguments.static FormulaFunction
findFirstMatch
(List<Object> arguments, Collection<FormulaFunction> formulaFunctions) Finds the first function that can accept the given values as arguments.static String
Given the function name and a string representation of the arguments, returns the properly formatted string representation of the whole expression.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.static boolean
matchArgumentCount
(int nArguments, FormulaFunction function) Check whether the function will accept the given number of arguments.static boolean
matchArgumentTypes
(List<Object> arguments, FormulaFunction function) Check whether the function will accept the given list of values as arguments.static boolean
matchArgumentTypes
(List<Object> arguments, FormulaFunction function, boolean allowNull) Checks whether the function will accept the given arguments.
-
Constructor Details
-
FormulaFunctions
public FormulaFunctions()
-
-
Method Details
-
matchArgumentTypes
Check whether the function will accept the given list of values as arguments.- Parameters:
arguments
- the possible valuesfunction
- 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 argumentsfunction
- a functionallowNull
- whether the function should allow null arguments- Returns:
- true if the function can accept the given arguments
-
matchArgumentCount
Check whether the function will accept the given number of arguments.- Parameters:
nArguments
- the number of argumentsfunction
- 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 valuesformulaFunctions
- 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 typesformulaFunctions
- a collection of functions- Returns:
- the first function that accepts the give arguments
-
formatSignature
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
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 nameargs
- the arguments- Returns:
- the expression text representation
-