|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectma.glasnost.orika.metadata.ClassMapBuilder<A,B>
A - B - public class ClassMapBuilder<A,B>
ClassMapBuilder provides a fluent API which can be used to define a mapping from one class to another.
| Nested Class Summary | |
|---|---|
static class |
ClassMapBuilder.Factory
|
| Constructor Summary | |
|---|---|
protected |
ClassMapBuilder(Type<A> aType,
Type<B> bType,
MapperFactory mapperFactory,
PropertyResolverStrategy propertyResolver,
DefaultFieldMapper... defaults)
|
| Method Summary | ||
|---|---|---|
protected void |
addFieldMap(FieldMap fieldMap)
|
|
ClassMapBuilder<A,B> |
byDefault(DefaultFieldMapper... withDefaults)
Configures this class-map builder to employ the default property mapping behavior to any properties that have not already been mapped or excluded; if any DefaultFieldMapper instances are passed, they will be used (instead of those configured on the builder) to attempt a property name match if a direct match is not found. |
|
ClassMapBuilder<A,B> |
byDefault(MappingHint[] mappingHints)
Deprecated. use byDefault(DefaultFieldMapper...) instead |
|
ClassMapBuilder<A,B> |
byDefault(MappingHint hint0,
MappingHint... mappingHints)
Deprecated. use byDefault(DefaultFieldMapper...) instead |
|
ClassMapBuilder<A,B> |
constructorA(String... args)
Declares a constructor to be used for the A type with the specified arguments. |
|
ClassMapBuilder<A,B> |
constructorB(String... args)
Declares a constructor to be used for the B type with the specified arguments. |
|
ClassMapBuilder<A,B> |
customize(Mapper<A,B> customizedMapper)
Set the custom mapper to use for this mapping. |
|
ClassMapBuilder<A,B> |
customize(MapperBase<A,B> legacyCustomizedMapper)
Deprecated. use customize(Mapper) instead |
|
protected String |
describeClassMap()
|
|
ClassMapBuilder<A,B> |
exclude(String fieldName)
Exclude the specified field from mapping |
|
ClassMapBuilder<A,B> |
field(Property.Builder fieldA,
Property.Builder fieldB)
|
|
ClassMapBuilder<A,B> |
field(Property.Builder fieldA,
String fieldNameB)
|
|
ClassMapBuilder<A,B> |
field(Property fieldA,
Property fieldB)
|
|
ClassMapBuilder<A,B> |
field(Property fieldA,
String fieldNameB)
|
|
ClassMapBuilder<A,B> |
field(String fieldNameA,
Property.Builder fieldB)
|
|
ClassMapBuilder<A,B> |
field(String fieldNameA,
Property fieldB)
|
|
ClassMapBuilder<A,B> |
field(String fieldNameA,
String fieldNameB)
Map a field in both directions |
|
ClassMapBuilder<A,B> |
fieldAToB(String fieldNameA,
String fieldNameB)
Map a field in one direction only (from fieldNameA to fieldNameB) |
|
ClassMapBuilder<A,B> |
fieldBToA(String fieldNameB,
String fieldNameA)
Map a field in one direction only (from fieldNameB to fieldNameA) |
|
FieldMapBuilder<A,B> |
fieldMap(Property.Builder fieldA,
Property.Builder fieldB,
boolean byDefault)
|
|
FieldMapBuilder<A,B> |
fieldMap(Property.Builder fieldA,
String fieldNameB,
boolean byDefault)
|
|
FieldMapBuilder<A,B> |
fieldMap(Property fieldA,
Property fieldB,
boolean byDefault)
|
|
FieldMapBuilder<A,B> |
fieldMap(Property fieldA,
String fieldNameB,
boolean byDefault)
|
|
FieldMapBuilder<A,B> |
fieldMap(String a)
Create a fieldMap for the particular field (same property name used in both types) |
|
FieldMapBuilder<A,B> |
fieldMap(String a,
boolean byDefault)
Create a fieldMap for the particular field (same property name used in both types) |
|
FieldMapBuilder<A,B> |
fieldMap(String fieldNameA,
Property.Builder fieldB,
boolean byDefault)
|
|
FieldMapBuilder<A,B> |
fieldMap(String fieldNameA,
Property fieldB,
boolean byDefault)
|
|
FieldMapBuilder<A,B> |
fieldMap(String fieldNameA,
String fieldNameB)
Create a fieldMap for the particular field mapping |
|
FieldMapBuilder<A,B> |
fieldMap(String fieldNameA,
String fieldNameB,
boolean byDefault)
Create a fieldMap for the particular field mapping |
|
Type<A> |
getAType()
|
|
Type<B> |
getBType()
|
|
protected DefaultFieldMapper[] |
getDefaultFieldMappers()
|
|
protected Set<FieldMap> |
getMappedFields()
|
|
protected Set<String> |
getMappedPropertiesForTypeA()
|
|
protected Set<String> |
getMappedPropertiesForTypeB()
|
|
protected Set<String> |
getPropertiesForTypeA()
|
|
protected Set<String> |
getPropertiesForTypeB()
|
|
protected PropertyResolverStrategy |
getPropertyResolver()
|
|
protected boolean |
isNestedPropertyExpression(String expression)
Determines whether the provided string is a valid property expression |
|
static
|
map(Class<A> aType,
Class<B> bType)
Deprecated. use MapperFactory.classMap(Class, Class) instead |
|
static
|
map(Class<A> aType,
Type<B> bType)
Deprecated. use MapperFactory.classMap(Class, Type) instead |
|
static
|
map(Type<A> aType,
Class<B> bType)
Deprecated. use MapperFactory.classMap(Type, Class) instead |
|
static
|
map(Type<A> aType,
Type<B> bType)
Deprecated. use MapperFactory.classMap(Type, Type) instead |
|
ClassMapBuilder<A,B> |
mapNulls(boolean destinationsMappedOnNull)
|
|
ClassMapBuilder<A,B> |
mapNullsInReverse(boolean sourcesMappedOnNull)
|
|
void |
register()
Registers the ClassMap defined by this builder with it's initiating MapperFactory |
|
protected Property |
resolveProperty(Type type,
String expr)
Resolves a property for the particular type, based on the provided property expression |
|
protected Property |
resolvePropertyForA(String expr)
Resolves a property expression for this builder's 'A' type |
|
protected Property |
resolvePropertyForB(String expr)
Resolves a property expression for this builder's 'B' type |
|
ClassMap<A,B> |
toClassMap()
Produces a ClassMap instance based on the configurations defined on this ClassMapBuilder. |
|
String |
toString()
|
|
|
use(Class<?> aParentClass,
Class<?> bParentClass)
Configure this ClassMapBuilder to use an existing mapping (for parent classes) defined from aParentClass to bParentClass. |
|
|
use(Type<?> aParentType,
Type<?> bParentType)
Configure this ClassMapBuilder to use an existing mapping (for parent classes) defined from aParentClass to bParentClass. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
protected ClassMapBuilder(Type<A> aType,
Type<B> bType,
MapperFactory mapperFactory,
PropertyResolverStrategy propertyResolver,
DefaultFieldMapper... defaults)
aType - bType - propertyResolver - defaults - | Method Detail |
|---|
public ClassMapBuilder<A,B> field(String fieldNameA,
String fieldNameB)
fieldNameA - property name in type AfieldNameB - property name in type B
public ClassMapBuilder<A,B> fieldAToB(String fieldNameA,
String fieldNameB)
fieldNameA - the (source) fieldName from type AfieldNameB - the (destination) fieldName from type B
public ClassMapBuilder<A,B> fieldBToA(String fieldNameB,
String fieldNameA)
fieldNameB - the (source) fieldName from type BfieldNameA - the (destination) fieldName from type A
public FieldMapBuilder<A,B> fieldMap(String a)
a -
public FieldMapBuilder<A,B> fieldMap(String a,
boolean byDefault)
a - byDefault -
public FieldMapBuilder<A,B> fieldMap(String fieldNameA,
String fieldNameB)
fieldNameA - the name of the field in type AfieldNameB - the name of the field in type B
public FieldMapBuilder<A,B> fieldMap(String fieldNameA,
String fieldNameB,
boolean byDefault)
fieldNameA - the name of the field in type AfieldNameB - the name of the field in type BbyDefault - whether the field mapping has been provided by default
public FieldMapBuilder<A,B> fieldMap(Property fieldA,
Property fieldB,
boolean byDefault)
fieldA - fieldB - byDefault -
public FieldMapBuilder<A,B> fieldMap(String fieldNameA,
Property fieldB,
boolean byDefault)
fieldA - fieldB - byDefault -
public FieldMapBuilder<A,B> fieldMap(Property fieldA,
String fieldNameB,
boolean byDefault)
fieldA - fieldNameB - byDefault -
public FieldMapBuilder<A,B> fieldMap(Property.Builder fieldA,
Property.Builder fieldB,
boolean byDefault)
fieldA - fieldB - byDefault -
public FieldMapBuilder<A,B> fieldMap(String fieldNameA,
Property.Builder fieldB,
boolean byDefault)
fieldA - fieldB - byDefault -
public FieldMapBuilder<A,B> fieldMap(Property.Builder fieldA,
String fieldNameB,
boolean byDefault)
fieldA - fieldNameB - byDefault -
public ClassMapBuilder<A,B> field(Property fieldA,
Property fieldB)
fieldA - fieldB - byDefault -
public ClassMapBuilder<A,B> field(String fieldNameA,
Property fieldB)
fieldA - fieldB - byDefault -
public ClassMapBuilder<A,B> field(Property fieldA,
String fieldNameB)
fieldA - fieldNameB - byDefault -
public ClassMapBuilder<A,B> field(Property.Builder fieldA,
Property.Builder fieldB)
fieldA - fieldB - byDefault -
public ClassMapBuilder<A,B> field(String fieldNameA,
Property.Builder fieldB)
fieldA - fieldB - byDefault -
public ClassMapBuilder<A,B> field(Property.Builder fieldA,
String fieldNameB)
fieldA - fieldNameB - byDefault -
public ClassMapBuilder<A,B> exclude(String fieldName)
fieldName - the name of the field/property to exclude
@Deprecated public final ClassMapBuilder<A,B> customize(MapperBase<A,B> legacyCustomizedMapper)
customize(Mapper) instead
legacyCustomizedMapper -
public ClassMapBuilder<A,B> customize(Mapper<A,B> customizedMapper)
customizedMapper -
public <X,Y> ClassMapBuilder<A,B> use(Class<?> aParentClass,
Class<?> bParentClass)
aParentClass to bParentClass.
aParentClass - the source class of the parent mappingbParentClass - the destination class of the parent mapping
public <X,Y> ClassMapBuilder<A,B> use(Type<?> aParentType,
Type<?> bParentType)
aParentClass to bParentClass.
aParentType - the source type of the parent mappingbParentType - the destination type of the parent mapping
public ClassMapBuilder<A,B> byDefault(DefaultFieldMapper... withDefaults)
withDefaults - zero or more DefaultFieldMapper instances to apply during the default mapping;
if none are supplied, the configured DefaultFieldMappers for the builder (if any) should be used.
@Deprecated
public final ClassMapBuilder<A,B> byDefault(MappingHint hint0,
MappingHint... mappingHints)
byDefault(DefaultFieldMapper...) instead
hint0 - first hintmappingHints - remaining hints
@Deprecated public final ClassMapBuilder<A,B> byDefault(MappingHint[] mappingHints)
byDefault(DefaultFieldMapper...) instead
mappingHints -
public ClassMap<A,B> toClassMap()
public ClassMapBuilder<A,B> mapNulls(boolean destinationsMappedOnNull)
destinationsMappedOnNull - true|false to indicate whether the destination
properties of this class map's fields should be set to null (when mapping in the forward
direction) if the source property's value is null
public ClassMapBuilder<A,B> mapNullsInReverse(boolean sourcesMappedOnNull)
sourcesMappedOnNull - true|false to indicate whether the source properties of
this class map's fields should be set to null (when mapping in the reverse direction)
if the destination property's value is null
public void register()
protected String describeClassMap()
public static final <A,B> ClassMapBuilder<A,B> map(Class<A> aType,
Class<B> bType)
MapperFactory.classMap(Class, Class) instead
aType
and bType.
aType - bType -
public static final <A,B> ClassMapBuilder<A,B> map(Type<A> aType,
Type<B> bType)
MapperFactory.classMap(Type, Type) instead
aType - bType -
public static final <A,B> ClassMapBuilder<A,B> map(Class<A> aType,
Type<B> bType)
MapperFactory.classMap(Class, Type) instead
aType - bType -
public static final <A,B> ClassMapBuilder<A,B> map(Type<A> aType,
Class<B> bType)
MapperFactory.classMap(Type, Class) instead
aType - bType -
protected boolean isNestedPropertyExpression(String expression)
expression - the expression to evaluate
protected Property resolveProperty(Type type,
String expr)
type - the type to resolveexpr - the property expression to resolve
protected Property resolvePropertyForA(String expr)
expr - the property expression
protected Property resolvePropertyForB(String expr)
expr - the property expression
public Type<A> getAType()
getAType in interface MappedTypePair<A,B>public Type<B> getBType()
getBType in interface MappedTypePair<A,B>protected void addFieldMap(FieldMap fieldMap)
protected Set<String> getMappedPropertiesForTypeA()
protected Set<String> getMappedPropertiesForTypeB()
protected Set<FieldMap> getMappedFields()
protected Set<String> getPropertiesForTypeA()
protected Set<String> getPropertiesForTypeB()
protected DefaultFieldMapper[] getDefaultFieldMappers()
protected PropertyResolverStrategy getPropertyResolver()
public ClassMapBuilder<A,B> constructorA(String... args)
args - the arguments identifying the constructor to be used
public ClassMapBuilder<A,B> constructorB(String... args)
args - the arguments identifying the constructor to be used
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||