info.javelot.functionalj.reflect
Interface DynReflect

All Known Implementing Classes:
CglibDynReflect, DynReflectImpl, JdkDynReflect

public interface DynReflect

This interface represents the ability to produce functions by using reflection, without requiring the types nor the number of parameters. The target constructor or method is determined dynamically according to the number and types of the parameters that are provided when the function is called. Also, a list of possible targets is maintained when calling the other methods of the FunctionN interface. If, at any point, there are no possible targets, a FunctionException is thrown.

See the StdReflect documentation for more details.

Author:
Copyright © 2006 Frederic Daoud

Method Summary
 FunctionN constructor(Class p_class)
          Produces a function that creates an instance of the specified class, using a constructor.
 FunctionN constructor(String p_class)
          Version of constructor(Class) that accepts a String to specify the class by name.
 FunctionN instanceFunction(Class p_class, String p_name)
          Produces a function that invokes the instance method of specified class which has the specified name, using the parameters passed to the function.
 FunctionN instanceFunction(Object p_object, String p_name)
          Produces a function that invokes the instance method on the provided object which has the specified name.
 FunctionN instanceFunction(String p_class, String p_name)
          Version of instanceFunction(Class,String) that accepts a String to specify the class by name.
 FunctionN staticFunction(Class p_class, String p_name)
          Produces a function that invokes the static method of specified class which has the specified name, using the parameters passed to the function.
 FunctionN staticFunction(String p_class, String p_name)
          Version of staticFunction(Class,String) that accepts a String to specify the class by name.
 

Method Detail

constructor

FunctionN constructor(Class p_class)
                      throws FunctionException
Produces a function that creates an instance of the specified class, using a constructor.

Parameters:
p_class - an instance of this class will be created by the function. The parameters to the constructor will be the same as the parameters provided to the function.
Returns:
a function that passes its parameters to the constructor and returns an instance of the class.
Throws:
FunctionException - thrown if a matching constructor was not found.

constructor

FunctionN constructor(String p_class)
                      throws FunctionException
Version of constructor(Class) that accepts a String to specify the class by name.

Throws:
FunctionException

instanceFunction

FunctionN instanceFunction(Class p_class,
                           String p_name)
                           throws FunctionException
Produces a function that invokes the instance method of specified class which has the specified name, using the parameters passed to the function.

Parameters:
p_class - the class which contains the instance method to be invoked by the produced function.
p_name - the name of the method.
Returns:
a function that invokes the method on the object that is specified as its first parameter, passing the rest of its parameters to the method and returning the result of the invocation.
Throws:
FunctionException - thrown if a matching instance method was not found.

instanceFunction

FunctionN instanceFunction(String p_class,
                           String p_name)
                           throws FunctionException
Version of instanceFunction(Class,String) that accepts a String to specify the class by name.

Throws:
FunctionException

instanceFunction

FunctionN instanceFunction(Object p_object,
                           String p_name)
                           throws FunctionException
Produces a function that invokes the instance method on the provided object which has the specified name.

Parameters:
p_object - the object on which the instance method will be invoked by the produced function.
p_name - the name of the method.
Returns:
a function that invokes the method on the object, passing its parameters to the method and returning the result.
Throws:
FunctionException - thrown if a matching instance method was not found.

staticFunction

FunctionN staticFunction(Class p_class,
                         String p_name)
                         throws FunctionException
Produces a function that invokes the static method of specified class which has the specified name, using the parameters passed to the function.

Parameters:
p_class - the class which contains the static method to be invoked. The parameters to the method will be the same as the parameters provided to the function.
p_name - the name of the method.
Returns:
a function that passes its parameters to the static method and returns the result of invoking it.
Throws:
FunctionException - thrown if a matching static method was not found.

staticFunction

FunctionN staticFunction(String p_class,
                         String p_name)
                         throws FunctionException
Version of staticFunction(Class,String) that accepts a String to specify the class by name.

Throws:
FunctionException