Class TLcdDataTypeMapping
This class is used to build an ILcdObjectTransformation
that transforms instances
of one data object type into another data object type. This transformation transforms
source data objects into target data objects by transforming the data properties of the
source data objects one by one using ILcdDataPropertyTransformation
instances.
-
Constructor Summary
ConstructorsConstructorDescriptionTLcdDataTypeMapping
(TLcdDataType aSourceType, TLcdDataType aTargetType) Creates a new data type mapping.TLcdDataTypeMapping
(TLcdDataType aSourceType, TLcdDataType aTargetType, boolean aTransformEmptyProperties) Creates a new data type mapping. -
Method Summary
Modifier and TypeMethodDescriptionCreates and returns a transformation that is capable of transforming instances of the source type into instances of the target type.Returns the inverse of this mapping.void
mapProperty
(TLcdDataProperty aSourceProperty, TLcdDataProperty aTargetProperty) Maps the given source property on the target property.void
mapProperty
(TLcdDataProperty aSourceProperty, TLcdDataProperty aTargetProperty, ILcdObjectTransformation aTransformation) Maps the given source property on the given target property.void
mapProperty
(TLcdDataProperty aSourceProperty, ILcdDataPropertyTransformation aTransformation) Maps the given source property using the given transformation on the target object.void
mapProperty
(String aSourceProperty, ILcdDataPropertyTransformation aTransformation) Maps the given source property using the given transformation on the target object.void
mapProperty
(String aSourceProperty, String aTargetProperty) Maps the source property with the given name on the target property with the given name.void
mapProperty
(String aSourceProperty, String aTargetProperty, ILcdObjectTransformation aTransformation) Maps the source property with the given name on the target property with the given name.void
mapTargetProperty
(TLcdDataProperty aTargetProperty, ILcdObjectTransformation aTransformation) Maps the given target property using the given transformation.void
mapTargetProperty
(String aTargetProperty, ILcdObjectTransformation aTransformation) Maps the given target property using the given transformation.
-
Constructor Details
-
TLcdDataTypeMapping
Creates a new data type mapping. Properties on the source data withnull
value will not be transformed by default.- Parameters:
aSourceType
- the source typeaTargetType
- the target type
-
TLcdDataTypeMapping
public TLcdDataTypeMapping(TLcdDataType aSourceType, TLcdDataType aTargetType, boolean aTransformEmptyProperties) Creates a new data type mapping.- Parameters:
aSourceType
- the source typeaTargetType
- the target typeaTransformEmptyProperties
- indicates whether the created transformations should make an attempt to transform properties without a value. This may be useful if anull
value in the source data should be mapped onto a non-null default value in the target data.
-
-
Method Details
-
getTargetType
-
getSourceType
-
mapProperty
Maps the given source property using the given transformation on the target object.- Parameters:
aSourceProperty
- the source propertyaTransformation
- the transformation that is to be used to transform values for the given source property
-
mapProperty
public void mapProperty(TLcdDataProperty aSourceProperty, ILcdDataPropertyTransformation aTransformation) Maps the given source property using the given transformation on the target object. This property mapping is always uni-directional. To make the type mapping bi-directional, probably additional property mappings need to be registered on this object's inverse type mapping.- Parameters:
aSourceProperty
- the source property to mapaTransformation
- the transformation to use to map the source property
-
mapProperty
Maps the source property with the given name on the target property with the given name.- Parameters:
aSourceProperty
- the source propertyaTargetProperty
- the target property- See Also:
-
mapProperty
Maps the given source property on the target property. Transformations created by this mapping will convert values of the source property to values acceptable for the target property using the object transformation provider that is given as argument when creating the transformations.- Parameters:
aSourceProperty
- the source propertyaTargetProperty
- the target property
-
mapProperty
public void mapProperty(String aSourceProperty, String aTargetProperty, ILcdObjectTransformation aTransformation) Maps the source property with the given name on the target property with the given name. Source values are transformed into target values using the given transformation- Parameters:
aSourceProperty
- the source propertyaTargetProperty
- the target propertyaTransformation
- the transformation used to transform source values into target values
-
mapProperty
public void mapProperty(TLcdDataProperty aSourceProperty, TLcdDataProperty aTargetProperty, ILcdObjectTransformation aTransformation) Maps the given source property on the given target property. Source values are transformed into target values using the given transformation- Parameters:
aSourceProperty
- the source propertyaTargetProperty
- the target propertyaTransformation
- the transformation used to transform source values into target values
-
mapTargetProperty
Maps the given target property using the given transformation. The transformation should transform instances of this object's source type into appropriate values for the given target property. This property mapping is always uni-directional. To make the type mapping bi-directional, additional property mappings have to be registered on this object's inverse type mapping.
This method is for instance used to map properties whose values depends on the value of multiple source properties.
- Parameters:
aTargetProperty
- the name of the target propertyaTransformation
- the transformation used to transform a source instance into a value for the target property
-
mapTargetProperty
public void mapTargetProperty(TLcdDataProperty aTargetProperty, ILcdObjectTransformation aTransformation) Maps the given target property using the given transformation. The transformation should transform instances of this object's source type into appropriate values for the given target property.
This method is for instance used to map properties whose values depends on the value of multiple source properties.
- Parameters:
aTargetProperty
- the target propertyaTransformation
- the transformation used to transform a source instance into a value for the target property
-
getInverse
Returns the inverse of this mapping. The inverse is typically used in case properties are not mapped one-on-one from source type to target type.- Returns:
- the inverse of this mapping
-
createTransformation
Creates and returns a transformation that is capable of transforming instances of the source type into instances of the target type.
The returned object transformation transforms objects as follows:
- A new instance is created of the target type using
type.newInstance()
. - Each source property for which a mapping is provided (using one of the
mapProperty
methods) is transformed. The order in which the property transformations are applied is implementation dependent and should not be relied upon. - The new target instance is returned.
- Parameters:
aProvider
- the transformation provider- Returns:
- a transformation that is capable of transforming instances of the source type into instances of the target type
- A new instance is created of the target type using
-