S - the type of the source argument to convertT - the type of the target object to create from the source@API(status=STABLE,
since="5.10")
public abstract class TypedArgumentConverter<S,T>
extends java.lang.Object
implements ArgumentConverter
TypedArgumentConverter is an abstract base class for
ArgumentConverter implementations that always convert objects of a
given source type into a given target type.ArgumentConverter,
SimpleArgumentConverter| Modifier and Type | Field and Description |
|---|---|
private java.lang.Class<S> |
sourceType |
private java.lang.Class<T> |
targetType |
| Modifier | Constructor and Description |
|---|---|
protected |
TypedArgumentConverter(java.lang.Class<S> sourceType,
java.lang.Class<T> targetType)
Create a new
TypedArgumentConverter. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
convert(java.lang.Object source,
ParameterContext context)
Convert the supplied
source object according to the supplied
context. |
protected abstract T |
convert(S source)
Convert the supplied
source object of type S into an object
of type T. |
private final java.lang.Class<S> sourceType
private final java.lang.Class<T> targetType
protected TypedArgumentConverter(java.lang.Class<S> sourceType, java.lang.Class<T> targetType)
TypedArgumentConverter.sourceType - the type of the argument to convert; never nulltargetType - the type of the target object to create from the source;
never nullpublic final java.lang.Object convert(java.lang.Object source,
ParameterContext context)
throws ArgumentConversionException
ArgumentConvertersource object according to the supplied
context.convert in interface ArgumentConvertersource - the source object to convert; may be nullcontext - the parameter context where the converted object will be
used; never nullnull but only if the target
type is a reference typeArgumentConversionException - if an error occurs during the
conversionprotected abstract T convert(S source) throws ArgumentConversionException
source object of type S into an object
of type T.source - the source object to convert; may be nullnull but only if the target
type is a reference typeArgumentConversionException - if an error occurs during the
conversion