org.javimmutable.collections.util
Class ReflectionFunctions

java.lang.Object
  extended by org.javimmutable.collections.util.ReflectionFunctions

public final class ReflectionFunctions
extends Object

Contains static constructors for creating FuncN objects that call methods using reflection.


Nested Class Summary
static class ReflectionFunctions.ReflectionException
          Encapsulates the various checked exceptions that can be thrown by the java reflection methods.
static class ReflectionFunctions.StaticMismatchException
          Exception thrown if caller requests a static class but reflection finds a non-static class (or vice versa).
 
Method Summary
static
<R> Func0<R>
method(Object obj, String name)
          Returns a Func0 instance that calls the specified non-static method on the specified java object.
static
<P1,R> Func1<P1,R>
method(Object obj, String name, Class<P1> arg1Class)
          Returns a Func1 instance that calls the specified non-static method on the specified java object.
static
<P1,P2,R> Func2<P1,P2,R>
method(Object obj, String name, Class<P1> arg1Class, Class<P2> arg2Class)
          Returns a Func2 instance that calls the specified non-static method on the specified java object.
static
<P1,P2,P3,R>
Func3<P1,P2,P3,R>
method(Object obj, String name, Class<P1> arg1Class, Class<P2> arg2Class, Class<P3> arg3Class)
          Returns a Func3 instance that calls the specified non-static method on the specified java object.
static
<P1,P2,P3,P4,R>
Func4<P1,P2,P3,P4,R>
method(Object obj, String name, Class<P1> arg1Class, Class<P2> arg2Class, Class<P3> arg3Class, Class<P4> arg4Class)
          Returns a Func4 instance that calls the specified non-static method on the specified java object.
static
<OT,R> Func1<OT,R>
method(String name, Class<OT> klass)
          Returns a Func1 instance that calls the specified non-static method on a java object passed as the parameter of the function.
static
<P1,OT,R> Func2<P1,OT,R>
method(String name, Class<P1> arg1Class, Class<OT> klass)
          Returns a Func2 instance that calls the specified non-static method on a java object passed as the last parameter of the Func2.
static
<P1,P2,OT,R>
Func3<P1,P2,OT,R>
method(String name, Class<P1> arg1Class, Class<P2> arg2Class, Class<OT> klass)
          Returns a Func3 instance that calls the specified non-static method on a java object passed as the last parameter of the Func3.
static
<P1,P2,P3,OT,R>
Func4<P1,P2,P3,OT,R>
method(String name, Class<P1> arg1Class, Class<P2> arg2Class, Class<P3> arg3Class, Class<OT> klass)
          Returns a Func4 instance that calls the specified non-static method on a java object passed as the last parameter of the Func4.
static
<R> Func0<R>
staticMethod(Class klass, String name)
          Returns a Func0 instance that calls the specified static method on the specified java object.
static
<P1,R> Func1<P1,R>
staticMethod(Class klass, String name, Class<P1> arg1Class)
          Returns a Func3 instance that calls the specified static method on the specified java object.
static
<P1,P2,R> Func2<P1,P2,R>
staticMethod(Class klass, String name, Class<P1> arg1Class, Class<P2> arg2Class)
          Returns a Func2 instance that calls the specified static method on the specified java object.
static
<P1,P2,P3,R>
Func3<P1,P2,P3,R>
staticMethod(Class klass, String name, Class<P1> arg1Class, Class<P2> arg2Class, Class<P3> arg3Class)
          Returns a Func3 instance that calls the specified static method on the specified java object.
static
<P1,P2,P3,P4,R>
Func4<P1,P2,P3,P4,R>
staticMethod(Class klass, String name, Class<P1> arg1Class, Class<P2> arg2Class, Class<P3> arg3Class, Class<P4> arg4Class)
          Returns a Func4 instance that calls the specified static method on the specified java object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

method

public static <R> Func0<R> method(Object obj,
                                  String name)
Returns a Func0 instance that calls the specified non-static method on the specified java object.

Type Parameters:
R - the return type of the function
Parameters:
obj - the object whose method should be invoked
name - the name of the method to invoke
Returns:

method

public static <P1,R> Func1<P1,R> method(Object obj,
                                        String name,
                                        Class<P1> arg1Class)
Returns a Func1 instance that calls the specified non-static method on the specified java object.

Type Parameters:
P1 - parameter 1 type
R - the return type of the function
Parameters:
obj - the object whose method should be invoked
name - the name of the method to invoke
arg1Class - Class of parameter 1 of the method
Returns:

method

public static <P1,P2,R> Func2<P1,P2,R> method(Object obj,
                                              String name,
                                              Class<P1> arg1Class,
                                              Class<P2> arg2Class)
Returns a Func2 instance that calls the specified non-static method on the specified java object.

Type Parameters:
P1 - parameter 1 type
P2 - parameter 2 type
R -
Parameters:
obj - the object whose method should be invoked
name - the name of the method to invoke
arg1Class - Class of parameter 1 of the method
arg2Class - Class of parameter 2 of the method
Returns:

method

public static <P1,P2,P3,R> Func3<P1,P2,P3,R> method(Object obj,
                                                    String name,
                                                    Class<P1> arg1Class,
                                                    Class<P2> arg2Class,
                                                    Class<P3> arg3Class)
Returns a Func3 instance that calls the specified non-static method on the specified java object.

Type Parameters:
P1 - parameter 1 type
P2 - parameter 2 type
P3 - parameter 3 type
R - the return type of the function
Parameters:
obj - the object whose method should be invoked
name - the name of the method to invoke
arg1Class - Class of parameter 1 of the method
arg2Class - Class of parameter 2 of the method
arg3Class - Class of parameter 3 of the method
Returns:

method

public static <P1,P2,P3,P4,R> Func4<P1,P2,P3,P4,R> method(Object obj,
                                                          String name,
                                                          Class<P1> arg1Class,
                                                          Class<P2> arg2Class,
                                                          Class<P3> arg3Class,
                                                          Class<P4> arg4Class)
Returns a Func4 instance that calls the specified non-static method on the specified java object.

Type Parameters:
P1 - parameter 1 type
P2 - parameter 2 type
P3 - parameter 3 type
P4 - parameter 4 type
R - the return type of the function
Parameters:
obj - the object whose method should be invoked
name - the name of the method to invoke
arg1Class - Class of parameter 1 of the method
arg2Class - Class of parameter 2 of the method
arg3Class - Class of parameter 3 of the method
arg4Class - Class of parameter 4 of the method
Returns:

method

public static <OT,R> Func1<OT,R> method(String name,
                                        Class<OT> klass)
Returns a Func1 instance that calls the specified non-static method on a java object passed as the parameter of the function. These functions are useful for invoking the same method on all objects returned by a Cursor.

Parameters:
name - name of the method to invoke
klass - class of the instance object parameter
Returns:

method

public static <P1,OT,R> Func2<P1,OT,R> method(String name,
                                              Class<P1> arg1Class,
                                              Class<OT> klass)
Returns a Func2 instance that calls the specified non-static method on a java object passed as the last parameter of the Func2. These functions are useful for invoking the same method with the same arguments on all objects returned by a Cursor. The instance object is the last parameter to facilitate the use of Curry.of().

Parameters:
name - name of the method to invoke
arg1Class - Class of parameter 1 of the method
klass - class of the instance object parameter
Returns:

method

public static <P1,P2,OT,R> Func3<P1,P2,OT,R> method(String name,
                                                    Class<P1> arg1Class,
                                                    Class<P2> arg2Class,
                                                    Class<OT> klass)
Returns a Func3 instance that calls the specified non-static method on a java object passed as the last parameter of the Func3. These functions are useful for invoking the same method with the same arguments on all objects returned by a Cursor. The instance object is the last parameter to facilitate the use of Curry.of().

Parameters:
name - name of the method to invoke
arg1Class - Class of parameter 1 of the method
arg2Class - Class of parameter 2 of the method
klass - class of the instance object parameter
Returns:

method

public static <P1,P2,P3,OT,R> Func4<P1,P2,P3,OT,R> method(String name,
                                                          Class<P1> arg1Class,
                                                          Class<P2> arg2Class,
                                                          Class<P3> arg3Class,
                                                          Class<OT> klass)
Returns a Func4 instance that calls the specified non-static method on a java object passed as the last parameter of the Func4. These functions are useful for invoking the same method with the same arguments on all objects returned by a Cursor. The instance object is the last parameter to facilitate the use of Curry.of().

Parameters:
name - name of the method to invoke
arg1Class - Class of parameter 1 of the method
arg2Class - Class of parameter 2 of the method
arg3Class - Class of parameter 3 of the method
klass - class of the instance object parameter
Returns:

staticMethod

public static <R> Func0<R> staticMethod(Class klass,
                                        String name)
Returns a Func0 instance that calls the specified static method on the specified java object.

Type Parameters:
R - the return type of the function
Parameters:
name - the name of the method to invoke
Returns:

staticMethod

public static <P1,R> Func1<P1,R> staticMethod(Class klass,
                                              String name,
                                              Class<P1> arg1Class)
Returns a Func3 instance that calls the specified static method on the specified java object.

Type Parameters:
P1 - parameter 1 type
R - the return type of the function
Parameters:
name - the name of the method to invoke
arg1Class - Class of parameter 1 of the method
Returns:

staticMethod

public static <P1,P2,R> Func2<P1,P2,R> staticMethod(Class klass,
                                                    String name,
                                                    Class<P1> arg1Class,
                                                    Class<P2> arg2Class)
Returns a Func2 instance that calls the specified static method on the specified java object.

Type Parameters:
P1 - parameter 1 type
P2 - parameter 2 type
R - the return type of the function
Parameters:
name - the name of the method to invoke
arg1Class - Class of parameter 1 of the method
arg2Class - Class of parameter 2 of the method
Returns:

staticMethod

public static <P1,P2,P3,R> Func3<P1,P2,P3,R> staticMethod(Class klass,
                                                          String name,
                                                          Class<P1> arg1Class,
                                                          Class<P2> arg2Class,
                                                          Class<P3> arg3Class)
Returns a Func3 instance that calls the specified static method on the specified java object.

Type Parameters:
P1 - parameter 1 type
P2 - parameter 2 type
P3 - parameter 3 type
R - the return type of the function
Parameters:
name - the name of the method to invoke
arg1Class - Class of parameter 1 of the method
arg2Class - Class of parameter 2 of the method
arg3Class - Class of parameter 3 of the method
Returns:

staticMethod

public static <P1,P2,P3,P4,R> Func4<P1,P2,P3,P4,R> staticMethod(Class klass,
                                                                String name,
                                                                Class<P1> arg1Class,
                                                                Class<P2> arg2Class,
                                                                Class<P3> arg3Class,
                                                                Class<P4> arg4Class)
Returns a Func4 instance that calls the specified static method on the specified java object.

Type Parameters:
P1 - parameter 1 type
P2 - parameter 2 type
P3 - parameter 3 type
P4 - parameter 4 type
R - the return type of the function
Parameters:
name - the name of the method to invoke
arg1Class - Class of parameter 1 of the method
arg2Class - Class of parameter 2 of the method
arg3Class - Class of parameter 3 of the method
arg4Class - Class of parameter 4 of the method
Returns:


Copyright © 2014 Burton Computer Corporation. All rights reserved.