org.flexiblepower.observation
public final class ObservationTranslationHelper extends java.lang.Object
Observation.getValueMap()
and
Observation.getValue(String)
methods. It finds the all the getX() methods of a class using the
getGetterMethods(Class)
function and it can test if it is a valid java bean (see isJavaBean(Class)
.Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
executeMethod(java.lang.Object object,
java.lang.reflect.Method method)
Executes the method on the object.
|
static java.util.Map<java.lang.String,java.lang.reflect.Method> |
getGetterMethods(java.lang.Class<?> clazz) |
static java.lang.Object |
getMember(java.lang.Object object,
java.lang.String name)
Gets the member of the given object.
|
static boolean |
isJavaBean(java.lang.Class<?> type) |
public static java.util.Map<java.lang.String,java.lang.reflect.Method> getGetterMethods(java.lang.Class<?> clazz)
clazz
- The class from which it will detect all the getter methods.Method
as value.public static boolean isJavaBean(java.lang.Class<?> type)
type
- The class that will be checked if it is a java beanisPrimite(Class)
.public static java.lang.Object getMember(java.lang.Object object, java.lang.String name)
object
- The object on which to call the getter methods.name
- The name of the member that is needed. For deep referencing use the dot as a seperator.public static java.lang.Object executeMethod(java.lang.Object object, java.lang.reflect.Method method)
AccessibleObject.setAccessible(boolean)
first to make sure it can
be called. Then it calls the Method.invoke(Object, Object...)
to really execute the method. This will
also handle any Exception thrown by the invocation by wrapping it in a RuntimeException.object
- The object on which to call the method.method
- The Method
that should be used.