Class Reflector
java.lang.Object
org.apache.ibatis.reflection.Reflector
This class represents a cached set of class definition information that allows for easy mapping between property
names and getter/setter methods.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Constructor<?> private static final MethodHandleprivate final String[]private final Class<?> private final String[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddDefaultConstructor(Class<?> clazz) private voidprivate voidaddGetField(Field field) private voidaddGetMethod(String name, Method method, boolean isAmbiguous) private voidaddGetMethods(Method[] methods) private voidprivate voidaddRecordGetMethods(Method[] methods) private voidaddSetField(Field field) private voidaddSetMethod(String name, Method method) private voidaddSetMethods(Method[] methods) private voidaddUniqueMethods(Map<String, Method> uniqueMethods, Method[] methods) static booleanChecks whether can control member accessible.findPropertyName(String name) private Method[]getClassMethods(Class<?> clazz) This method returns an array containing all methods declared in this class and any superclass.Constructor<?> String[]Gets an array of the readable properties for an object.getGetInvoker(String propertyName) Class<?> getGetterType(String propertyName) Gets the type for a property getter.private static MethodHandleString[]Gets an array of the writable properties for an object.getSetInvoker(String propertyName) Class<?> getSetterType(String propertyName) Gets the type for a property setter.private StringgetSignature(Method method) Class<?> getType()Gets the name of the class the instance provides information for.booleanbooleanCheck to see if a class has a readable property by name.booleanCheck to see if a class has a writable property by name.private static booleanClass.isRecord() alternative for Java 15 and older.private booleanisValidPropertyName(String name) private MethodpickBetterSetter(Method setter1, Method setter2, String property) private voidresolveGetterConflicts(Map<String, List<Method>> conflictingGetters) private voidresolveSetterConflicts(Map<String, List<Method>> conflictingSetters) private Class<?> typeToClass(Type src)
-
Field Details
-
isRecordMethodHandle
-
type
-
readablePropertyNames
-
writablePropertyNames
-
setMethods
-
getMethods
-
setTypes
-
getTypes
-
defaultConstructor
-
caseInsensitivePropertyMap
-
-
Constructor Details
-
Reflector
-
-
Method Details
-
addRecordGetMethods
-
addDefaultConstructor
-
addGetMethods
-
resolveGetterConflicts
-
addGetMethod
-
addSetMethods
-
addMethodConflict
-
resolveSetterConflicts
-
pickBetterSetter
-
addSetMethod
-
typeToClass
-
addFields
-
addSetField
-
addGetField
-
isValidPropertyName
-
getClassMethods
This method returns an array containing all methods declared in this class and any superclass. We use this method, instead of the simplerClass.getMethods(), because we want to look for private methods as well.- Parameters:
clazz- The class- Returns:
- An array containing all methods in this class
-
addUniqueMethods
-
getSignature
-
canControlMemberAccessible
public static boolean canControlMemberAccessible()Checks whether can control member accessible.- Returns:
- If can control member accessible, it return true
- Since:
- 3.5.0
-
getType
Gets the name of the class the instance provides information for.- Returns:
- The class name
-
getDefaultConstructor
-
hasDefaultConstructor
public boolean hasDefaultConstructor() -
getSetInvoker
-
getGetInvoker
-
getSetterType
-
getGetterType
-
getGetablePropertyNames
Gets an array of the readable properties for an object.- Returns:
- The array
-
getSetablePropertyNames
Gets an array of the writable properties for an object.- Returns:
- The array
-
hasSetter
Check to see if a class has a writable property by name.- Parameters:
propertyName- - the name of the property to check- Returns:
- True if the object has a writable property by the name
-
hasGetter
Check to see if a class has a readable property by name.- Parameters:
propertyName- - the name of the property to check- Returns:
- True if the object has a readable property by the name
-
findPropertyName
-
isRecord
Class.isRecord() alternative for Java 15 and older. -
getIsRecordMethodHandle
-