public class TLcdDataModelMapping extends Object
TLcdTransformer
. Typical usage is as follows:
TLcdDataModelMapping mapping = new TLcdDataModelMapping(sourceDataModel, targetDataModel);
// optionally, add or change the mapping between two types
mapping.mapType(...);
// create and configure the transformer
TLcdTransformer toTargetModelTransformer = new TLcdTransformer();
mapping.configure(toTargetModelTransformer);
// the transformer is ready to be used
ILcdDataObject dataObjectFromTargetModel = toTargetModelTransformer.transform(dataObjectFromSourceModel);
TLcdDataModelMappingValidator
Constructor and Description |
---|
TLcdDataModelMapping()
Constructs a new instance.
|
TLcdDataModelMapping(TLcdDataModel aSourceModel,
TLcdDataModel aTargetModel)
Constructs a new instance that automatically maps the given source model to the given target model
(see also
mapDataModel(TLcdDataModel, TLcdDataModel...) ). |
TLcdDataModelMapping(TLcdDataModel aSourceModel,
TLcdDataModel aTargetModel,
boolean aTransformEmptyProperties)
Constructs a new instance that automatically maps the given source model to the given target model
(see also
mapDataModel(TLcdDataModel, TLcdDataModel...) ). |
Modifier and Type | Method and Description |
---|---|
void |
configure(TLcdTransformer aTransformerSFCT)
Registers transformations for the configured mappings and for all types in the
mapped
source data models (if it is not explicitly ignored and if a target type could be found). |
TLcdDataModelMapping |
getInverse()
Returns the inverse of this mapping.
|
void |
ignore(TLcdDataProperty aProperty)
Marks the given property that it should not be automatically mapped, even if its
declaring data model would be mapped.
|
void |
ignore(TLcdDataType aType)
Marks the given type that it should not be automatically mapped, even if its
declaring data model would be mapped.
|
void |
mapDataModel(TLcdDataModel aSourceModel,
TLcdDataModel... aTargetModels)
Maps a source data model on one or more target data models.
|
TLcdDataTypeMapping |
mapType(TLcdDataType aSourceType)
Maps the given source type on a type with the same name in the target data models.
|
TLcdDataTypeMapping |
mapType(TLcdDataType aSourceType,
TLcdDataType aTargetType)
Maps the source type on the target type (and vice versa) using a
TLcdDataTypeMapping . |
void |
mapType(TLcdDataType aSourceType,
TLcdDataType aTargetType,
ILcdObjectTransformation aTransformation)
Maps the source type on the target type using the given transformation.
|
public TLcdDataModelMapping()
null
value will not be transformed by default.public TLcdDataModelMapping(TLcdDataModel aSourceModel, TLcdDataModel aTargetModel)
mapDataModel(TLcdDataModel, TLcdDataModel...)
).
Properties on the source data with null
value will not be transformed by default.aSourceModel
- a source modelaTargetModel
- a target modelpublic TLcdDataModelMapping(TLcdDataModel aSourceModel, TLcdDataModel aTargetModel, boolean aTransformEmptyProperties)
mapDataModel(TLcdDataModel, TLcdDataModel...)
).aSourceModel
- a source modelaTargetModel
- a target modelaTransformEmptyProperties
- indicates whether the transformations, created by this data model
mapping, should make an attempt to transform properties without
a value. This may be useful if a null
value in the source
data should be mapped onto a non-null default value in the target data.public void mapDataModel(TLcdDataModel aSourceModel, TLcdDataModel... aTargetModels)
Maps a source data model on one or more target data models. All types declared in the
source data model will be automatically mapped (unless they are explicitly mapped,
see mapType(TLcdDataType, TLcdDataType, ILcdObjectTransformation)
) to a type
with the same name from the target data models.
Calling this method will never cause any explicit type mappings to be overridden.
aSourceModel
- the source data modelaTargetModels
- the target data modelspublic void ignore(TLcdDataType aType)
aType
- the type to ignorepublic void ignore(TLcdDataProperty aProperty)
aProperty
- the property to ignorepublic TLcdDataTypeMapping mapType(TLcdDataType aSourceType)
Maps the given source type on a type with the same name in the target data models. The source type should be a data object type.
Before this method is called, the source data model should already have been mapped on one or more target data models. Otherwise the implementation will not be able to find a target type and an IllegalArgumentException will be thrown.
aSourceType
- the source typeIllegalArgumentException
- when no target type could be foundmapDataModel(TLcdDataModel, TLcdDataModel...)
,
mapType(TLcdDataType, TLcdDataType)
public TLcdDataTypeMapping mapType(TLcdDataType aSourceType, TLcdDataType aTargetType)
TLcdDataTypeMapping
.
The returned type mapping can be used to further control how properties are mapped from
the source type to the target type.
Both source and target type are assumed to be data object types. Calling this method overrides
the default mapping done by mapDataModel(TLcdDataModel, TLcdDataModel...)
.aSourceType
- the source typeaTargetType
- the target typeIllegalArgumentException
- in case one of the parameters is null
public void mapType(TLcdDataType aSourceType, TLcdDataType aTargetType, ILcdObjectTransformation aTransformation)
aSourceType
- the source typeaTargetType
- the target typeaTransformation
- the transformation that maps the source on the target typepublic void configure(TLcdTransformer aTransformerSFCT)
mapped
source data models (if it is not explicitly ignored and if a target type could be found).aTransformerSFCT
- the transformer to configurepublic TLcdDataModelMapping getInverse()