public final class ReflectionUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
GET_PREFIX |
static java.lang.String |
SET_PREFIX |
Modifier and Type | Method and Description |
---|---|
static java.lang.reflect.Method |
findGetter(java.lang.Object object,
java.lang.String fieldName)
Returns the getter method associated with the object's field.
|
static java.lang.reflect.Method |
findSetter(java.lang.Object object,
java.lang.String fieldName,
java.lang.Class<?> argumentType)
Returns the setter method associated with the object's field.
|
public static final java.lang.String SET_PREFIX
public static final java.lang.String GET_PREFIX
public static java.lang.reflect.Method findGetter(java.lang.Object object, java.lang.String fieldName)
object
- the objectfieldName
- the name of the fieldjava.lang.NullPointerException
- if object or fieldName is nullSuperCsvReflectionException
- if the getter doesn't exist or is not visiblepublic static java.lang.reflect.Method findSetter(java.lang.Object object, java.lang.String fieldName, java.lang.Class<?> argumentType)
This method handles any autoboxing/unboxing of the argument passed to the setter (e.g. if the setter type is a
primitive int
but the argument passed to the setter is an Integer
) 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 Object
or interface
respectively).
object
- the objectfieldName
- the name of the fieldargumentType
- the type to be passed to the setterjava.lang.NullPointerException
- if object, fieldName or fieldType is nullSuperCsvReflectionException
- if the setter doesn't exist or is not visibleCopyright © 2007-2012 Super CSV. All Rights Reserved.