public class ALDParametrizedClassDataIOHelper extends Object
Constructor and Description |
---|
ALDParametrizedClassDataIOHelper() |
Modifier and Type | Method and Description |
---|---|
private static Method |
findHookMethod(Class<?> c,
String hook)
Find hook method of parameter in class or any of its super classes.
|
static HashMap<String,Field> |
getAnnotatedFields(Class<?> myclass)
Return all fields for member variables of
myclass or any of its super classes
which is annotated with ALDClassParameter . |
static Object |
getValue(Field field,
Object obj)
Return the value of the member variable associated with
field in
the object obj . |
static void |
setValue(Field field,
Object obj,
Object value)
Sets the value of the member variable associated with
field
in the object obj . |
static void |
setValue(String name,
Object obj,
Object value)
Sets the field with given
name of object obj to value . |
public static HashMap<String,Field> getAnnotatedFields(Class<?> myclass)
myclass
or any of its super classes
which is annotated with ALDClassParameter
.myclass
- public static Object getValue(Field field, Object obj)
field
in
the object obj
.field
- field of the member variableobj
- from which to return the valuepublic static void setValue(Field field, Object obj, Object value) throws IllegalAccessException
field
in the object obj
.
Primitive datatype can not be set from a value == null.
field
- field of the member variableobj
- from which to return the valueIllegalAccessException
private static Method findHookMethod(Class<?> c, String hook)
c
- Class of parameter object in question.hook
- Hook function to be searched for.public static void setValue(String name, Object obj, Object value) throws IllegalAccessException
name
of object obj
to value
.
The method recursively iterates over all class fields and fields of super classes to find the requested field. An exception is thrown if the requested field could not be found or accessed.
name
- Name of field to set.obj
- Object in which field is to set.value
- Value to set for the field.IllegalAccessException
Copyright © 2010–2021 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.