public class DataTransformer extends Attribute
A base class for a transformer that can be registered with ContentType
to add support for converting between content types.
It should rarely be necessary to implement a custom DataTransformer as the built-in content types will handle most cases, and if a custom ContentType is introduced, it will generally know how to convert to and from the basic types. This would only be necessary for converting between two content types that are not base types and do not know about each other.
Constructor and Description |
---|
DataTransformer() |
Modifier and Type | Method and Description |
---|---|
boolean |
supports(ContentType source,
ContentType target)
Checks to see if this transformer supports the given source and target content types.
|
<T,V> V |
transform(ContentType<T> source,
ContentType<V> target,
T data)
Transforms data from one content type to another.
|
public boolean supports(ContentType source, ContentType target)
Checks to see if this transformer supports the given source and target content types.
source
- The source content type.target
- The target content type.public <T,V> V transform(ContentType<T> source, ContentType<V> target, T data)
Transforms data from one content type to another.
T
- The source type representation class.V
- The target type representation class.source
- The source typetarget
- The target typedata
- The data to be converted.Copyright © 2021. All Rights Reserved.