public abstract class TypeConverterSupport extends Object implements TypeConverter
TypeConverter
implementations.
Implementators need only to implement the TypeConverter.convertTo(Class, org.apache.camel.Exchange, Object)
method, and can rely on the default implementations of the other methods from this support class.Constructor and Description |
---|
TypeConverterSupport() |
Modifier and Type | Method and Description |
---|---|
boolean |
allowNull()
Whether the type converter allows returning null as a valid response.
|
<T> T |
convertTo(Class<T> type,
Object value)
Converts the value to the specified type
|
<T> T |
mandatoryConvertTo(Class<T> type,
Exchange exchange,
Object value)
Converts the value to the specified type in the context of an exchange
Used when conversion requires extra information from the current
exchange (such as encoding).
|
<T> T |
mandatoryConvertTo(Class<T> type,
Object value)
Converts the value to the specified type
|
<T> T |
tryConvertTo(Class<T> type,
Exchange exchange,
Object value)
Tries to convert the value to the specified type in the context of an exchange,
returning null if not possible to convert.
|
<T> T |
tryConvertTo(Class<T> type,
Object value)
Tries to convert the value to the specified type,
returning null if not possible to convert.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
convertTo
public TypeConverterSupport()
public boolean allowNull()
TypeConverter
allowNull
in interface TypeConverter
public <T> T convertTo(Class<T> type, Object value) throws TypeConversionException
TypeConverter
convertTo
in interface TypeConverter
type
- the requested typevalue
- the value to be convertedTypeConversionException
- is thrown if error during type conversionpublic <T> T mandatoryConvertTo(Class<T> type, Object value) throws TypeConversionException, NoTypeConversionAvailableException
TypeConverter
mandatoryConvertTo
in interface TypeConverter
type
- the requested typevalue
- the value to be convertedTypeConversionException
- is thrown if error during type conversionNoTypeConversionAvailableException
- if no type converters exists to convert to the given typepublic <T> T mandatoryConvertTo(Class<T> type, Exchange exchange, Object value) throws TypeConversionException, NoTypeConversionAvailableException
TypeConverter
mandatoryConvertTo
in interface TypeConverter
type
- the requested typeexchange
- the current exchangevalue
- the value to be convertedTypeConversionException
- is thrown if error during type conversionNoTypeConversionAvailableException
- if no type converters exists to convert to the given typepublic <T> T tryConvertTo(Class<T> type, Object value)
TypeConverter
tryConvertTo
in interface TypeConverter
type
- the requested typevalue
- the value to be convertedpublic <T> T tryConvertTo(Class<T> type, Exchange exchange, Object value)
TypeConverter
tryConvertTo
in interface TypeConverter
type
- the requested typeexchange
- the current exchangevalue
- the value to be convertedApache Camel