Class TLcdTransformer
- Direct Known Subclasses:
TLcdGMLTransformer
Object that can transform an object from one model to another. Transformations are
implemented by delegation to an appropriate ILcdObjectTransformation
that
is registered on this object's transformation provider.
This object is thread safe as long as the transformations that are registered on its provider are thread safe.
- Since:
- 11.0
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreates a new transformation context.Gets the inverse of this transformer.Returns the transformation provider used by this transformer to retrieve object transformations.transform
(ILcdDataObject aObject) Transforms the given object with a new transformation context.transform
(ILcdDataObject aObject, Map<Object, Object> aContext) Transforms the given object with the given transformation context.Transforms the given object of the specified type with the given transformation context.transformTo
(ILcdDataObject aObject, TLcdDataType aTargetType) Transforms the given object to the specified target type with a new given transformation context.transformTo
(ILcdDataObject aObject, TLcdDataType aTargetType, Map<Object, Object> aContext) Transforms the given object to the specified target type with the given transformation context.transformTo
(Object aObject, TLcdDataType aSourceType, TLcdDataType aTargetType, Map<Object, Object> aContext) Transforms the given object of the specified type to the specified target type with the given transformation context.
-
Constructor Details
-
TLcdTransformer
public TLcdTransformer()
-
-
Method Details
-
getProvider
Returns the transformation provider used by this transformer to retrieve object transformations. The object transformation provider needs to be configured with appropriate transformation instances in order for this transformer to be able to perform any object transformations.- Returns:
- the transformation provider used by this transformer to retrieve object transformations.
-
transform
Transforms the given object with a new transformation context. The transformer will look in its provider for a transformation that can transform objects of the given type. If one such transformation is found, the object is transformed using that transformation. Otherwise anIllegalArgumentException
is thrown to indicate that the object can't be transformed.- Parameters:
aObject
- the object to transform- Returns:
- the transformed object
- Throws:
IllegalArgumentException
- if the object cannot be transformed- See Also:
-
transformTo
Transforms the given object to the specified target type with a new given transformation context.- Parameters:
aObject
- the object to transformaTargetType
- the type of the transformed object- Returns:
- the transformed object
- Throws:
IllegalArgumentException
- if the object cannot be transformed- See Also:
-
transform
Transforms the given object with the given transformation context. The transformer will look in its provider for a transformation that can transform objects of the given type. If one such transformation is found, the object is transformed using that transformation. Otherwise anIllegalArgumentException
is thrown to indicate that the object can't be transformed.- Parameters:
aObject
- the object to transformaContext
- the transformation context- Returns:
- the transformed object
- Throws:
IllegalArgumentException
- if the object cannot be transformed- See Also:
-
transformTo
public Object transformTo(ILcdDataObject aObject, TLcdDataType aTargetType, Map<Object, Object> aContext) Transforms the given object to the specified target type with the given transformation context.- Parameters:
aObject
- the object to transformaTargetType
- the type of the transformed objectaContext
- the transformation context- Returns:
- the transformed object
- Throws:
IllegalArgumentException
- if the object cannot be transformed- See Also:
-
transform
Transforms the given object of the specified type with the given transformation context.
The object is assumed to be of the given type. The transformer will look in its provider for a transformation that can transform objects of the given type. If one such transformation is found, the object is transformed using that transformation. Otherwise anIllegalArgumentException
is thrown to indicate that the object can't be transformed.Note that this method is typically called for objects that do not implement
ILcdDataObject
. It allows for instance to transform string values into integers.- Parameters:
aObject
- the object to transformaType
- the type of the objectaContext
- the transformation context- Returns:
- the transformed object
- Throws:
IllegalArgumentException
- if the object cannot be transformed
-
transformTo
public Object transformTo(Object aObject, TLcdDataType aSourceType, TLcdDataType aTargetType, Map<Object, Object> aContext) Transforms the given object of the specified type to the specified target type with the given transformation context.
The object is assumed to be of the given source type. The transformer will look in its provider for a transformation that can transform objects between the given types If one such transformation is found, the object is transformed using that transformation. Otherwise anIllegalArgumentException
is thrown to indicate that the object can't be transformed.Note that this method is typically called for objects that do not implement
ILcdDataObject
. It allows for instance to transform string values into integers.- Parameters:
aObject
- the object to transformaSourceType
- the type of the original objectaTargetType
- the type of the transformed objectaContext
- the transformation context- Returns:
- the transformed object
- Throws:
IllegalArgumentException
- if the object cannot be transformed
-
getInverse
Gets the inverse of this transformer.- Returns:
- the inverse of this transformer.
-
createTransformationContext
Creates a new transformation context. This transformation context is passed as parameter when objects are transformed. This makes it possible for transformations to share information during the transformation.- Returns:
- a new mapping context
-