Package org.apache.ibatis.reflection
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 final String[]
private final Class<?>
private final String[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addDefaultConstructor
(Class<?> clazz) private void
private void
addGetField
(Field field) private void
addGetMethod
(String name, Method method, boolean isAmbiguous) private void
addGetMethods
(Class<?> clazz) private void
private void
addSetField
(Field field) private void
addSetMethod
(String name, Method method) private void
addSetMethods
(Class<?> clazz) private void
addUniqueMethods
(Map<String, Method> uniqueMethods, Method[] methods) static boolean
Checks 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.String[]
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 String
getSignature
(Method method) Class<?>
getType()
Gets the name of the class the instance provides information for.boolean
boolean
Check to see if a class has a readable property by name.boolean
Check to see if a class has a writable property by name.private boolean
isValidPropertyName
(String name) private Method
pickBetterSetter
(Method setter1, Method setter2, String property) private void
resolveGetterConflicts
(Map<String, List<Method>> conflictingGetters) private void
resolveSetterConflicts
(Map<String, List<Method>> conflictingSetters) private Class<?>
typeToClass
(Type src)
-
Field Details
-
type
-
readablePropertyNames
-
writablePropertyNames
-
setMethods
-
getMethods
-
setTypes
-
getTypes
-
defaultConstructor
-
caseInsensitivePropertyMap
-
-
Constructor Details
-
Reflector
-
-
Method Details
-
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
Gets the type for a property setter.- Parameters:
propertyName
- - the name of the property- Returns:
- The Class of the property setter
-
getGetterType
Gets the type for a property getter.- Parameters:
propertyName
- - the name of the property- Returns:
- The Class of the property getter
-
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
-