@Beta public class ReflectExtensions extends Object
| Constructor and Description |
|---|
ReflectExtensions() |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
get(Object receiver,
String fieldName)
Retrieves the value of the given accessible field of the given receiver.
|
Object |
invoke(Object receiver,
String methodName,
Object... args)
Invokes the first accessible method defined on the receiver'c class with the given name and
a parameter list compatible to the given arguments.
|
void |
set(Object receiver,
String fieldName,
Object value)
Sets the given value on an the receivers's accessible field with the given name.
|
public void set(Object receiver, String fieldName, Object value) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException
receiver - the receiver, never nullfieldName - the field's name, never nullvalue - the value to setNoSuchFieldException - see Class.getField(String)SecurityException - see Class.getField(String)IllegalAccessException - see Field.set(Object, Object)IllegalArgumentException - see Field.set(Object, Object)public <T> T get(Object receiver, String fieldName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException
receiver - the container of the field, not nullfieldName - the field's name, not nullNoSuchFieldException - see Class.getField(String)SecurityException - see Class.getField(String)IllegalAccessException - see Field.get(Object)IllegalArgumentException - see Field.get(Object)public Object invoke(Object receiver, String methodName, Object... args) throws SecurityException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
receiver - the method call receiver, not nullmethodName - the method name, not nullargs - the arguments for the method invocationnull if the method was of type void.SecurityException - see Class.getMethod(String, Class...)NoSuchMethodException - see Class.getMethod(String, Class...)IllegalAccessException - see Method.invoke(Object, Object...)IllegalArgumentException - see Method.invoke(Object, Object...)InvocationTargetException - see Method.invoke(Object, Object...)Copyright © 2015. All Rights Reserved.