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.
|
Set<String> |
getComputeDependencies(Property property)
Find the fields directly accessed by the compute method of the given computed property.
|
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(Method method)
Get
Property by it's getter, setter or compute method. |
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 getProperty(Method method)
Property
by it's getter, setter or compute method.method
- the getter, setter or compute methodpublic Property getNameField()
A name field annotated with NameColumn
or a field with name name
is
considered name field.
public Property[] getSequenceFields()
Sequence
fields.public Set<String> getComputeDependencies(Property property)
property
- the computed propertypublic 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