public final class ReflectionUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
bcall(Object expression) |
static <A> A |
call(Object expression)
Simple helper to avoid unnecessary
return null; statements when using run(Object),
run(Class, Object) or xfer(Object, Class, org.opencastproject.util.data.Function). |
static double |
dcall(Object expression) |
static int |
icall(Object expression) |
static long |
lcall(Object expression) |
static <A> void |
run(A a)
Call all parameterless methods of object
a. |
static <A,B extends A> |
run(Class<A> c,
B o)
Call all parameterless methods of
c on object o. |
static <A,B> A |
xfer(A target,
Class<B> source,
Function<A,? extends B> f)
Helper method for the transfer idiom.
|
public static <A> A call(Object expression)
return null; statements when using run(Object),
run(Class, Object) or xfer(Object, Class, org.opencastproject.util.data.Function).
Just wrap your expression like this return call(expr).public static boolean bcall(Object expression)
public static long lcall(Object expression)
public static int icall(Object expression)
public static double dcall(Object expression)
public static <A,B extends A> void run(Class<A> c, B o)
c on object o.
Does not call any bridge, synthetic or native methods and also no methods declared in Object.
public static <A> void run(A a)
a.
Does not call any bridge, synthetic or native methods and also no methods declared in Object.
public static <A,B> A xfer(A target,
Class<B> source,
Function<A,? extends B> f)
Take target and apply it to f. Take the result and call all
parameterless methods on it that are described by class source. This way f
is able to create a transfer object that sets all properties of target.
The advantage of this style is that each time the source class changes the compiler
will yield an error if a field is missed in the transfer. The common getter/setter or constructor idiom
does not detect errors of this kind at compile time.
Copyright © 2009–2020 Opencast Project. All rights reserved.