Class Introspection
- java.lang.Object
-
- org.assertj.core.util.introspection.Introspection
-
public final class Introspection extends Object
Utility methods related to JavaBeans Introspection.- Author:
- Alex Ruiz
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Introspection.MethodKey
-
Field Summary
Fields Modifier and Type Field Description private static boolean
bareNamePropertyMethods
private static Map<Introspection.MethodKey,Optional<Method>>
METHOD_CACHE
-
Constructor Summary
Constructors Modifier Constructor Description private
Introspection()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
canExtractBareNamePropertyMethods()
private static Method
findGetter(String propertyName, Object target)
private static Method
findMethod(String name, Object target)
private static Optional<Method>
findMethodByKey(Introspection.MethodKey key)
static Method
getPropertyGetter(String propertyName, Object target)
Returns the getterMethod
for a property matching the given name in the given object.private static boolean
isValidGetter(Method method)
private static String
propertyNotFoundErrorMessage(String message, String propertyName, Object target)
static void
setExtractBareNamePropertyMethods(boolean barenamePropertyMethods)
-
-
-
Field Detail
-
METHOD_CACHE
private static final Map<Introspection.MethodKey,Optional<Method>> METHOD_CACHE
-
bareNamePropertyMethods
private static boolean bareNamePropertyMethods
-
-
Method Detail
-
getPropertyGetter
public static Method getPropertyGetter(String propertyName, Object target)
Returns the getterMethod
for a property matching the given name in the given object.- Parameters:
propertyName
- the given property name.target
- the given object.- Returns:
- the getter
Method
for a property matching the given name in the given object. - Throws:
NullPointerException
- if the given property name isnull
.IllegalArgumentException
- if the given property name is empty.NullPointerException
- if the given object isnull
.IntrospectionError
- if the getter for the matching property cannot be found or accessed.
-
setExtractBareNamePropertyMethods
public static void setExtractBareNamePropertyMethods(boolean barenamePropertyMethods)
-
canExtractBareNamePropertyMethods
public static boolean canExtractBareNamePropertyMethods()
-
propertyNotFoundErrorMessage
private static String propertyNotFoundErrorMessage(String message, String propertyName, Object target)
-
isValidGetter
private static boolean isValidGetter(Method method)
-
findMethodByKey
private static Optional<Method> findMethodByKey(Introspection.MethodKey key)
-
-