Class ReflectionHelper
- java.lang.Object
-
- org.optaplanner.core.impl.domain.common.ReflectionHelper
-
public final class ReflectionHelper extends Object
Avoids the usage of Introspector to work on Android too.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertGetterMethod(Method getterMethod, Class<? extends Annotation> annotationClass)static voidassertReadMethod(Method readMethod, Class<? extends Annotation> annotationClass)static FieldgetField(Class<?> containingClass, String fieldName)static MethodgetGetterMethod(Class<?> containingClass, String propertyName)static StringgetGetterPropertyName(Member member)Returns the JavaBeans property name of the given member.static MethodgetSetterMethod(Class<?> containingClass, Class<?> propertyType, String propertyName)static MethodgetSetterMethod(Class<?> containingClass, String propertyName)static booleanhasField(Class<?> containingClass, String fieldName)static booleanhasGetterMethod(Class<?> containingClass, String propertyName)static booleanisGetterMethod(Method method)Checks whether the given method is a valid getter method according to the JavaBeans standard.static booleanisList(Type type)static booleanisMap(Type type)static booleanisMethodOverwritten(Method parentMethod, Class<?> childClass)static List<Object>transformArrayToList(Object arrayObject)
-
-
-
Method Detail
-
getGetterPropertyName
public static String getGetterPropertyName(Member member)
Returns the JavaBeans property name of the given member.- Parameters:
member- never null- Returns:
- null if the member is neither a field nor a getter method according to the JavaBeans standard
-
isGetterMethod
public static boolean isGetterMethod(Method method)
Checks whether the given method is a valid getter method according to the JavaBeans standard.- Parameters:
method- never null- Returns:
- true if the given method is a getter method
-
hasGetterMethod
public static boolean hasGetterMethod(Class<?> containingClass, String propertyName)
- Parameters:
containingClass- never nullpropertyName- never null- Returns:
- true if that getter exists
-
getGetterMethod
public static Method getGetterMethod(Class<?> containingClass, String propertyName)
- Parameters:
containingClass- never nullpropertyName- never null- Returns:
- sometimes null
-
hasField
public static boolean hasField(Class<?> containingClass, String fieldName)
- Parameters:
containingClass- never nullfieldName- never null- Returns:
- true if that field exists
-
getField
public static Field getField(Class<?> containingClass, String fieldName)
- Parameters:
containingClass- never nullfieldName- never null- Returns:
- sometimes null
-
getSetterMethod
public static Method getSetterMethod(Class<?> containingClass, Class<?> propertyType, String propertyName)
- Parameters:
containingClass- never nullpropertyType- never nullpropertyName- never null- Returns:
- null if it doesn't exist
-
getSetterMethod
public static Method getSetterMethod(Class<?> containingClass, String propertyName)
- Parameters:
containingClass- never nullpropertyName- never null- Returns:
- null if it doesn't exist
-
isMethodOverwritten
public static boolean isMethodOverwritten(Method parentMethod, Class<?> childClass)
-
assertGetterMethod
public static void assertGetterMethod(Method getterMethod, Class<? extends Annotation> annotationClass)
-
assertReadMethod
public static void assertReadMethod(Method readMethod, Class<? extends Annotation> annotationClass)
-
isMap
public static boolean isMap(Type type)
- Parameters:
type- never null- Returns:
- true if it is a
Map
-
isList
public static boolean isList(Type type)
- Parameters:
type- never null- Returns:
- true if it is a
List
-
-