Class ReflectionUtils
java.lang.Object
org.supercsv.util.ReflectionUtils
Provides useful utility methods for reflection.
- Since:
- 2.0.0
- Author:
- James Bassett
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic MethodfindGetter(Object object, String fieldName) Returns the getter method associated with the object's field.static MethodfindSetter(Object object, String fieldName, Class<?> argumentType) Returns the setter method associated with the object's field.
-
Field Details
-
SET_PREFIX
- See Also:
-
GET_PREFIX
- See Also:
-
IS_PREFIX
- See Also:
-
-
Method Details
-
findGetter
Returns the getter method associated with the object's field.- Parameters:
object- the objectfieldName- the name of the field- Returns:
- the getter method
- Throws:
NullPointerException- if object or fieldName is nullSuperCsvReflectionException- if the getter doesn't exist or is not visible
-
findSetter
Returns the setter method associated with the object's field.This method handles any autoboxing/unboxing of the argument passed to the setter (e.g. if the setter type is a primitive
intbut the argument passed to the setter is anInteger) by looking for a setter with the same type, and failing that checking for a setter with the corresponding primitive/wrapper type.It also allows for an argument type that is a subclass or implementation of the setter type (when the setter type is an
Objectorinterfacerespectively).- Parameters:
object- the objectfieldName- the name of the fieldargumentType- the type to be passed to the setter- Returns:
- the setter method
- Throws:
NullPointerException- if object, fieldName or fieldType is nullSuperCsvReflectionException- if the setter doesn't exist or is not visible
-