Package pi.util
Class ReflectionUtil
java.lang.Object
pi.util.ReflectionUtil
-
Method Summary
Modifier and TypeMethodDescriptiongetAllFields(List<Field> fields, Class<?> type) Recursively gets all fields of the specified type, respecting parent classes.static <T> TgetDefaultValue(Class<T> clazz) static Collection<Method>Gets the events for the specified type.static <T> Fieldstatic <T> Fieldstatic MethodRecursively gets a method by the specified name respecting the parent classes and the parameters of the declaration.getMethodsAnnotatedWith(Class<?> type, Class<? extends Annotation> annotation) static <T> Methodstatic <T> Collection<Method>getSetters(Class<T> cls) static <V> VgetStaticValue(Class<?> cls, String fieldName) static <T,C> boolean isWrapperType(Class<T> primitive, Class<C> potentialWrapper) static <T> booleanstatic <T> booleansetFieldValue(Class<T> cls, Object instance, String fieldName, String value) static <T,C> boolean
-
Method Details
-
getField
-
getField
-
getStaticValue
-
getAllFields
Recursively gets all fields of the specified type, respecting parent classes.- Parameters:
fields- The list containing all fields.type- The type to retrieve the fields from.- Returns:
- All fields of the specified type, including the fields of the parent classes.
-
getMethod
Recursively gets a method by the specified name respecting the parent classes and the parameters of the declaration.- Parameters:
name- The name of the method.type- The type on which to search for the method.parameterTypes- The types of the parameters defined by the method declaration.- Returns:
- The found method or null if no such method exists.
-
setValue
-
setEnumPropertyValue
-
getSetter
-
getSetters
-
isWrapperType
-
setFieldValue
-
getMethodsAnnotatedWith
public static List<Method> getMethodsAnnotatedWith(Class<?> type, Class<? extends Annotation> annotation) -
getEvents
Gets the events for the specified type.This will search for all methods that have a parameter of type
EventListenerand match the LITIENGINE's naming conventions for event subscription (i.e. the method name starts with one of the prefixes "add" or "on".- Parameters:
type- The type to inspect the events on.- Returns:
- All methods on the specified type that are considered to be events.
- See Also:
-
getDefaultValue
-