public class NameBasedMapConvention extends Object implements MapConvention
Modifier | Constructor and Description |
---|---|
protected |
NameBasedMapConvention()
Constructs instance.
|
Modifier and Type | Method and Description |
---|---|
NameBasedMapConvention |
disableFlattening()
Disables flattening feature as described in
enableFlattening() method. |
NameBasedMapConvention |
enableFlattening()
Enables flattening feature.
|
NameBasedMapConvention |
excludeDestinationMembers(String... members)
Sets list of destination members which will be excluded (ignored) by convention.
|
NameBasedMapConvention |
failIfNotAllDestinationMembersMapped()
Convention will fail during map building (see
getBindings(com.github.erchu.beancp.MappingInfo, java.lang.Class, java.lang.Class)
method) if not all destination properties are mapped. |
NameBasedMapConvention |
failIfNotAllSourceMembersMapped()
Convention will fail during map building (see
getBindings(com.github.erchu.beancp.MappingInfo, java.lang.Class, java.lang.Class)
method) if not all source properties are mapped. |
static NameBasedMapConvention |
get()
Returns mapping convention with following configuration
No destination members excluded
Maximum possible number of destination members included
Will not fail if not all destination members are mapped
Will not fail if not all source members are mapped
Flattening feature disabled
|
List<Binding> |
getBindings(MappingInfo mappingsInfo,
Class sourceClass,
Class destinationClass)
Returns list o bindings for specified source and destination classes.
|
NameBasedMapConvention |
includeDestinationMembers(String... members)
Sets list of destination members which will be included to matching.
|
public static NameBasedMapConvention get()
public NameBasedMapConvention includeDestinationMembers(String... members)
members
could be mapped by convention ignoring case. This list has lower priority
that exclude list specified by excludeDestinationMembers(java.lang.String...)
method.
Note that when you put some member on list then it is not guaranteed that it will be mapped — it still have to have matching source's member according to convention configuration.
members
- members to includepublic NameBasedMapConvention excludeDestinationMembers(String... members)
includeDestinationMembers(java.lang.String...)
method.
Note that when you put some member on list then it is not guaranteed that it will be mapped — it still have to have matching source's member according to convention configuration.
members
- members to ignorepublic NameBasedMapConvention enableFlattening()
setCustomerName
will be matched to getCustomer().getName()
because
CustomerName
property can be interpreted as path to Customer
and then to
Name
property.
class Customer { private String name; public String getName() { return name; } } class Order { private Customer customer; public Customer getCustomer() { return customer; } } class OrderDto { private String customerName; public void setCustomerName(final String customerName) { customerName = customerName; } public String getCustomerName() { return customerName; } }
This feature can be disabled by disableFlattening()
method.
public NameBasedMapConvention disableFlattening()
enableFlattening()
method. This is
opposite to enableFlattening()
method.public NameBasedMapConvention failIfNotAllDestinationMembersMapped()
getBindings(com.github.erchu.beancp.MappingInfo, java.lang.Class, java.lang.Class)
method) if not all destination properties are mapped.public NameBasedMapConvention failIfNotAllSourceMembersMapped()
getBindings(com.github.erchu.beancp.MappingInfo, java.lang.Class, java.lang.Class)
method) if not all source properties are mapped.public List<Binding> getBindings(MappingInfo mappingsInfo, Class sourceClass, Class destinationClass)
MapConvention
getBindings
in interface MapConvention
mappingsInfo
- current mapping information.sourceClass
- source class.destinationClass
- destination class.Copyright © 2014. All rights reserved.