gov.sns.tools.formula
Class FunctionFactory

java.lang.Object
  |
  +--gov.sns.tools.formula.FunctionFactory

public final class FunctionFactory
extends java.lang.Object

FunctionFactory allows convenient instantiation of objects that implement the Function interface.


Constructor Summary
protected FunctionFactory()
          Protected constructor hides the inherited public constructor.
 
Method Summary
static Function function(java.lang.Class targetClass, java.lang.String name)
          Convenience method for creating a single argument function that wraps a method from the specified target class.
static Function function(java.lang.Class targetClass, java.lang.String name, int numArgs)
          Convenience method for creating a multi-argument function that wraps a method from the specified target class.
static Function mathFunction(java.lang.String name)
          Instantiate a single argument function that wraps a method of the given name from the Math class.
static Function mathFunction(java.lang.String name, int numArgs)
          Instantiate a function that wraps a method of the given name from the Math class given the specified number of arguments of type double.
static Function maxFunction()
          Create a max function of multiple arguments.
static Function minFunction()
          Create a min function of multiple arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FunctionFactory

protected FunctionFactory()
Protected constructor hides the inherited public constructor.

Method Detail

mathFunction

public static Function mathFunction(java.lang.String name)
                             throws java.lang.NoSuchMethodException
Instantiate a single argument function that wraps a method of the given name from the Math class.

Parameters:
name - name of the method and the resulting function
Returns:
Function with the specified name
Throws:
java.lang.NoSuchMethodException - if there is no Math method of the given name which takes a single argument of type double

mathFunction

public static Function mathFunction(java.lang.String name,
                                    int numArgs)
                             throws java.lang.NoSuchMethodException
Instantiate a function that wraps a method of the given name from the Math class given the specified number of arguments of type double.

Parameters:
name - name of the method and the resulting function
numArgs - number of method arguments of type double
Returns:
Function with the specified name
Throws:
java.lang.NoSuchMethodException - if there is no Math method of the given name which takes numArgs arguments of type double

function

public static Function function(java.lang.Class targetClass,
                                java.lang.String name)
                         throws java.lang.NoSuchMethodException
Convenience method for creating a single argument function that wraps a method from the specified target class. It looks for a method with the specified name, in the specified class that takes a single argument of type double.

Parameters:
targetClass - class from which to get the method
name - name of the method and the resulting function
Returns:
Function with the specified name
Throws:
java.lang.NoSuchMethodException - if there is no method of the given name which takes a single argument of type double within targetClass

function

public static Function function(java.lang.Class targetClass,
                                java.lang.String name,
                                int numArgs)
                         throws java.lang.NoSuchMethodException
Convenience method for creating a multi-argument function that wraps a method from the specified target class. It looks for a method with the specified name, in the specified class that takes the specified number of arguments of type double.

Parameters:
targetClass - class from which to get the method
name - name of the method and the resulting function
numArgs - number of method arguments of type double
Returns:
Function with the specified name
Throws:
java.lang.NoSuchMethodException - if there is no method of the given name which takes numArgs arguments of type double within targetClass

minFunction

public static Function minFunction()
Create a min function of multiple arguments.

Returns:
minimum function that can take one or more arguments.

maxFunction

public static Function maxFunction()
Create a max function of multiple arguments.

Returns:
maximum function that can take one or more arguments.