|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.xtext.xbase.lib.util.ReflectExtensions
@Beta public class ReflectExtensions
Extension methods to simplify reflective invocation of methods and fields.
| Constructor Summary | |
|---|---|
ReflectExtensions()
|
|
| Method Summary | ||
|---|---|---|
|
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. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ReflectExtensions()
| Method Detail |
|---|
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 set
NoSuchFieldException - 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 null
NoSuchFieldException - 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 invocation
null 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...)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||