public class Mapper extends Object
Modifier and Type | Method and Description |
---|---|
Object |
get(Object bean,
String name)
Get the value of given property from the given bean.
|
Class<?> |
getBeanClass()
Get the bean class this mapper operates on.
|
Method |
getGetter(String name)
Get the getter method of the given property.
|
Property |
getNameField()
Get the property of the name field.
|
Property[] |
getProperties()
Get all the properties.
|
Property |
getProperty(String name)
Get the
Property of the given name. |
Property[] |
getSequenceFields()
Get all the
Sequence fields. |
Method |
getSetter(String name)
Get the setter method of the given property.
|
static Mapper |
of(Class<?> klass)
Create a
Mapper for the given Java Bean class by introspecting
all it's properties. |
Object |
set(Object bean,
String name,
Object value)
Set the property of the given bean with the provided value.
|
static <T> T |
toBean(Class<T> klass,
Map<String,Object> values)
Create an object of the given class mapping the given value map to it's
properties.
|
static Map<String,Object> |
toMap(Object bean)
Create a map from the given bean instance with property names are keys
and their respective values are map values.
|
public static Mapper of(Class<?> klass)
Mapper
for the given Java Bean class by introspecting
all it's properties.
If the Mapper
class has been previously created for the given
class, then the Mapper
class is retrieved from the cache.
klass
- the bean classMapper
for the given class.public Property[] getProperties()
Property
public Property getProperty(String name)
Property
of the given name.name
- name of the propertypublic Property getNameField()
NameColumn
or a field with
name name
is considered name field.public Property[] getSequenceFields()
Sequence
fields.public Class<?> getBeanClass()
public Method getGetter(String name)
name
- name of the propertypublic Method getSetter(String name)
name
- name of the propertypublic Object get(Object bean, String name)
null
if property doesn't exist.bean
- the beanname
- name of the propertypublic Object set(Object bean, String name, Object value)
bean
- the beanname
- name of the propertyvalue
- value for the propertypublic static <T> T toBean(Class<T> klass, Map<String,Object> values)
T
- type of the beanklass
- class of the beanvalues
- value map