|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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(java.lang.Object receiver,
java.lang.String fieldName)
Retrieves the value of the given accessible field of the given receiver. |
|
java.lang.Object |
invoke(java.lang.Object receiver,
java.lang.String methodName,
java.lang.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(java.lang.Object receiver,
java.lang.String fieldName,
java.lang.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(java.lang.Object receiver, java.lang.String fieldName, java.lang.Object value) throws java.lang.SecurityException, java.lang.NoSuchFieldException, java.lang.IllegalArgumentException, java.lang.IllegalAccessException
receiver
- the receiver, never null
fieldName
- the field's name, never null
value
- the value to set
java.lang.NoSuchFieldException
- see Class.getField(String)
java.lang.SecurityException
- see Class.getField(String)
java.lang.IllegalAccessException
- see Field.set(Object, Object)
java.lang.IllegalArgumentException
- see Field.set(Object, Object)
public <T> T get(java.lang.Object receiver, java.lang.String fieldName) throws java.lang.SecurityException, java.lang.NoSuchFieldException, java.lang.IllegalArgumentException, java.lang.IllegalAccessException
receiver
- the container of the field, not null
fieldName
- the field's name, not null
java.lang.NoSuchFieldException
- see Class.getField(String)
java.lang.SecurityException
- see Class.getField(String)
java.lang.IllegalAccessException
- see Field.get(Object)
java.lang.IllegalArgumentException
- see Field.get(Object)
public java.lang.Object invoke(java.lang.Object receiver, java.lang.String methodName, java.lang.Object... args) throws java.lang.SecurityException, java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException
receiver
- the method call receiver, not null
methodName
- the method name, not null
args
- the arguments for the method invocation
null
if the method was of type void.
java.lang.SecurityException
- see Class.getMethod(String, Class...)
java.lang.NoSuchMethodException
- see Class.getMethod(String, Class...)
java.lang.IllegalAccessException
- see Method.invoke(Object, Object...)
java.lang.IllegalArgumentException
- see Method.invoke(Object, Object...)
java.lang.reflect.InvocationTargetException
- see Method.invoke(Object, Object...)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |