public class ObjectTools extends Object
This tool contains some simple reflection implementations.
| Modifier and Type | Field and Description |
|---|---|
static String |
GET_PREFIX |
static String |
IS_PREFIX |
| Constructor and Description |
|---|
ObjectTools() |
| Modifier and Type | Method and Description |
|---|---|
static Object |
basicGet(Object object,
String name) |
static Object |
basicInsert(Object object,
String name,
Object value) |
static Object |
basicInvoke(Object object,
String name,
Object... values) |
static Object |
basicRemove(Object object,
String name,
Object value) |
static Object |
basicSet(Object object,
String name,
Object value) |
static Object |
convert(Object value,
String typeName,
ClassLoader classLoader) |
static <T> T |
createObject(Class clazz,
Class<T> expectedClass)
Create a new instance of Class "class"
|
static <T> T |
createObject(Class clazz,
Class<T> expectedClass,
Class[] parameterTypes,
Object[] parameters)
Create a new instance of Class "class"
|
static <T> T |
createObject(String className,
Class<T> expectedClass,
ClassLoader classLoader)
Create a new instance of Class "className" via "classLoader".
|
static Method |
findGetter(Object object,
String name) |
static Method |
findInserter(Object object,
String attribute,
Object value) |
static Method |
findMethod(Object object,
String methodName,
Object... parameters) |
static Method |
findMethodPrefixed(Object object,
String methodPrefix,
Object... parameters) |
static Method |
findRegister(Object object,
Object value) |
static Method |
findRemover(Object object,
String attribute,
Object value) |
static Method |
findSetter(Object object,
String attribute,
Object value) |
static Object |
get(Object object,
String name)
Get the value for field
name in object. |
static Object |
insert(Object object,
String name,
Object value)
Insert
value in the relation field name in
object. |
static Object |
invoke(Object object,
String name,
Object... values)
Invoke method
name in object. |
static boolean |
isAssignable(Class target,
Class source) |
static Object |
register(Object registry,
Object value) |
static Object |
remove(Object object,
String name,
Object value)
Remove
value in the relation field name in
object. |
static Object |
set(Object object,
String name,
Object value)
Set field
name in object to value. |
public static final String GET_PREFIX
public static final String IS_PREFIX
public static Object basicGet(Object object, String name) throws FieldException
FieldExceptionpublic static Object basicInsert(Object object, String name, Object value) throws FieldException
FieldExceptionpublic static Object basicInvoke(Object object, String name, Object... values) throws MethodException
MethodExceptionpublic static Object basicRemove(Object object, String name, Object value) throws FieldException
FieldExceptionpublic static Object basicSet(Object object, String name, Object value) throws FieldException
FieldExceptionpublic static Object convert(Object value, String typeName, ClassLoader classLoader) throws ObjectCreationException
ObjectCreationExceptionpublic static <T> T createObject(Class clazz, Class<T> expectedClass) throws ObjectCreationException
clazz - expectedClass - ObjectCreationExceptionpublic static <T> T createObject(Class clazz, Class<T> expectedClass, Class[] parameterTypes, Object[] parameters) throws ObjectCreationException
clazz - expectedClass - parameterTypes - parameters - ObjectCreationExceptionpublic static <T> T createObject(String className, Class<T> expectedClass, ClassLoader classLoader) throws ObjectCreationException
className - expectedClass - classLoader - ObjectCreationExceptionpublic static Method findGetter(Object object, String name) throws MethodException
MethodExceptionpublic static Method findInserter(Object object, String attribute, Object value) throws MethodException
MethodExceptionpublic static Method findMethod(Object object, String methodName, Object... parameters) throws MethodException
MethodExceptionpublic static Method findMethodPrefixed(Object object, String methodPrefix, Object... parameters) throws MethodException
MethodExceptionpublic static Method findRegister(Object object, Object value) throws MethodException
MethodExceptionpublic static Method findRemover(Object object, String attribute, Object value) throws MethodException
MethodExceptionpublic static Method findSetter(Object object, String attribute, Object value) throws MethodException
MethodExceptionpublic static Object get(Object object, String name) throws FieldException
name in object.object - name - name in object.IllegalAccessExceptionInvocationTargetExceptionNoSuchFieldExceptionFieldExceptionpublic static Object insert(Object object, String name, Object value) throws FieldException
value in the relation field name in
object. The value that was really inserted is returned (if
supported by the underlying object implementation). To be exact, the
result of the insert method invoked is returned.object - name - value - IllegalAccessExceptionInvocationTargetExceptionNoSuchFieldExceptionFieldExceptionpublic static Object invoke(Object object, String name, Object... values) throws MethodException
name in object. The result of the
invocation is returned.object - name - values - MethodExceptionpublic static Object register(Object registry, Object value) throws MethodException
MethodExceptionpublic static Object remove(Object object, String name, Object value) throws FieldException
value in the relation field name in
object. The value that was removed is returned (if supported
by the underlying object implementation). To be exact, the result of the
remove method invoked is returned.object - name - value - IllegalAccessExceptionInvocationTargetExceptionNoSuchFieldExceptionFieldExceptionpublic static Object set(Object object, String name, Object value) throws FieldException
name in object to value.
The old value is returned (if supported by the underlying object
implementation). To be exact, the result of the setter method invoked is
returned.object - name - value - IllegalAccessExceptionInvocationTargetExceptionNoSuchFieldExceptionFieldExceptionCopyright © 2013 intarsys consulting GmbH. All Rights Reserved.