S
- The source type of the converterT
- The target type of the converterpublic class ChainedConverter<S,T> extends Object implements ContentTypeConverter<S,T>
Constructor and Description |
---|
ChainedConverter(List<ContentTypeConverter<?,?>> delegates)
Creates a new instance that uses the given
delegates to form a chain of converters. |
Modifier and Type | Method and Description |
---|---|
static <S,T> ChainedConverter<S,T> |
calculateChain(Class<S> sourceType,
Class<T> targetType,
Collection<ContentTypeConverter<?,?>> candidates)
Returns a converter that can convert an IntermediateRepresentation from the given
sourceType to the
given targetType using a chain formed with given candidates . |
static <S,T> boolean |
canConvert(Class<S> sourceContentType,
Class<T> targetContentType,
List<ContentTypeConverter<?,?>> converters)
Indicates whether this converter is capable of converting the given
sourceContentType into
targetContentType , using the given converters . |
T |
convert(S original)
Converts the given object into another.
|
Class<S> |
expectedSourceType()
The expected type of input data.
|
Class<T> |
targetType()
The returned type of IntermediateRepresentation
|
public ChainedConverter(List<ContentTypeConverter<?,?>> delegates)
delegates
to form a chain of converters. Note that the
delegates
must for a Continuous chain, meaning that each item must produce an
IntermediateRepresentation of a type that can be consumed by the next delegate.
To automatically calculate a route between converters, see calculateChain(source, target, candidates)
delegates
- the chain of delegates to perform the conversionpublic static <S,T> ChainedConverter<S,T> calculateChain(Class<S> sourceType, Class<T> targetType, Collection<ContentTypeConverter<?,?>> candidates)
sourceType
to the
given targetType
using a chain formed with given candidates
. The returned converter
uses some (or all) of the given candidates
as delegates.S
- The source type of the converterT
- The target type of the convertersourceType
- The source type of the convertertargetType
- The target type of the convertercandidates
- The candidates to form a chain withCannotConvertBetweenTypesException
- if no converter can be created using given candidatespublic static <S,T> boolean canConvert(Class<S> sourceContentType, Class<T> targetContentType, List<ContentTypeConverter<?,?>> converters)
sourceContentType
into
targetContentType
, using the given converters
. When true
, it may use any
number of the given converters
to form a chain.S
- The content type of the source objectT
- The content type of the target objectsourceContentType
- The content type of the source objecttargetContentType
- The content type of the target objectconverters
- The converters eligible for usetrue
if this Converter can convert between the given types, using the given converters.
Otherwise false
.public T convert(S original)
ContentTypeConverter
SerializedObject
instance.convert
in interface ContentTypeConverter<S,T>
original
- the value to convertpublic Class<S> expectedSourceType()
ContentTypeConverter
expectedSourceType
in interface ContentTypeConverter<S,T>
public Class<T> targetType()
ContentTypeConverter
targetType
in interface ContentTypeConverter<S,T>
Copyright © 2010–2017. All rights reserved.