Package org.apache.camel.spi
Interface BulkTypeConverters
-
- All Superinterfaces:
Ordered
,TypeConverter
public interface BulkTypeConverters extends Ordered, TypeConverter
Bulk type converters that often comes out of the box with Apache Camel. Camel does a build phase where the Camel artifacts are scanned forConverter
s and then bulked together into a single source code generated class. This class is then used at runtime as an optimized and really fast way of using all those type converters by theTypeConverterRegistry
.
-
-
Field Summary
-
Fields inherited from interface org.apache.camel.TypeConverter
MISS_VALUE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default boolean
allowNull()
Whether the type converter allows returning null as a valid response.<T> T
convertTo(Class<?> from, Class<T> to, Exchange exchange, Object value)
Converts the value to the specified type in the context of an exchangedefault <T> T
convertTo(Class<T> type, Object value)
Converts the value to the specified typedefault <T> T
convertTo(Class<T> type, Exchange exchange, Object value)
Converts the value to the specified type in the context of an exchangedefault int
getOrder()
Gets the order.TypeConverter
lookup(Class<?> toType, Class<?> fromType)
Performs a lookup for a given type converter.default <T> T
mandatoryConvertTo(Class<?> from, Class<T> to, Exchange exchange, Object value)
Converts the value to the specified type in the context of an exchangedefault <T> T
mandatoryConvertTo(Class<T> type, Object value)
Converts the value to the specified typedefault <T> T
mandatoryConvertTo(Class<T> type, Exchange exchange, Object value)
Converts the value to the specified type in the context of an exchangeint
size()
Number of type converters includeddefault <T> T
tryConvertTo(Class<?> from, Class<T> to, Exchange exchange, Object value)
Tries to convert the value to the specified type, returning null if not possible to convert.default <T> T
tryConvertTo(Class<T> type, Object value)
Tries to convert the value to the specified type, returning null if not possible to convert.default <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.
-
-
-
Method Detail
-
lookup
TypeConverter lookup(Class<?> toType, Class<?> fromType)
Performs a lookup for a given type converter.- Parameters:
toType
- the type to convert tofromType
- the type to convert from- Returns:
- the type converter or null if not found.
-
convertTo
<T> T convertTo(Class<?> from, Class<T> to, Exchange exchange, Object value) throws TypeConversionException
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).- Parameters:
from
- the from typeto
- the to typeexchange
- the current exchangevalue
- the value to be converted- Returns:
- the converted value, null if no converter can covert this, or Void.class if a converter converted the value to null and was allowed to return null.
- Throws:
TypeConversionException
- is thrown if error during type conversion
-
tryConvertTo
default <T> T tryConvertTo(Class<?> from, Class<T> to, Exchange exchange, Object value) throws TypeConversionException
Tries to convert the value to the specified type, returning null if not possible to convert. This method will not throw an exception if an exception occurred during conversion.- Parameters:
from
- the from typeto
- the to typevalue
- the value to be converted- Returns:
- the converted value, or null if not possible to convert
- Throws:
TypeConversionException
-
mandatoryConvertTo
default <T> T mandatoryConvertTo(Class<?> from, Class<T> to, Exchange exchange, Object value) throws TypeConversionException, NoTypeConversionAvailableException
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).- Parameters:
from
- the from typeto
- the to typeexchange
- the current exchangevalue
- the value to be converted- Returns:
- the converted value, is never null
- Throws:
TypeConversionException
- is thrown if error during type conversionNoTypeConversionAvailableException
- if no type converters exists to convert to the given type
-
size
int size()
Number of type converters included
-
getOrder
default int getOrder()
Description copied from interface:Ordered
Gets the order. Use low numbers for higher priority. Normally the sorting will start from 0 and move upwards. So if you want to be last then useInteger.MAX_VALUE
or egOrdered.LOWEST
.
-
allowNull
default boolean allowNull()
Description copied from interface:TypeConverter
Whether the type converter allows returning null as a valid response. By default null is not a valid response, returning false from this method.- Specified by:
allowNull
in interfaceTypeConverter
-
convertTo
default <T> T convertTo(Class<T> type, Object value) throws TypeConversionException
Description copied from interface:TypeConverter
Converts the value to the specified type- Specified by:
convertTo
in interfaceTypeConverter
- Parameters:
type
- the requested typevalue
- the value to be converted- Returns:
- the converted value, or null if not possible to convert
- Throws:
TypeConversionException
- is thrown if error during type conversion
-
convertTo
default <T> T convertTo(Class<T> type, Exchange exchange, Object value) throws TypeConversionException
Description copied from interface:TypeConverter
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).- Specified by:
convertTo
in interfaceTypeConverter
- Parameters:
type
- the requested typeexchange
- the current exchangevalue
- the value to be converted- Returns:
- the converted value, or null if not possible to convert
- Throws:
TypeConversionException
- is thrown if error during type conversion
-
mandatoryConvertTo
default <T> T mandatoryConvertTo(Class<T> type, Object value) throws TypeConversionException, NoTypeConversionAvailableException
Description copied from interface:TypeConverter
Converts the value to the specified type- Specified by:
mandatoryConvertTo
in interfaceTypeConverter
- Parameters:
type
- the requested typevalue
- the value to be converted- Returns:
- the converted value, is never null
- Throws:
TypeConversionException
- is thrown if error during type conversionNoTypeConversionAvailableException
- if no type converters exists to convert to the given type
-
mandatoryConvertTo
default <T> T mandatoryConvertTo(Class<T> type, Exchange exchange, Object value) throws TypeConversionException, NoTypeConversionAvailableException
Description copied from interface:TypeConverter
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).- Specified by:
mandatoryConvertTo
in interfaceTypeConverter
- Parameters:
type
- the requested typeexchange
- the current exchangevalue
- the value to be converted- Returns:
- the converted value, is never null
- Throws:
TypeConversionException
- is thrown if error during type conversionNoTypeConversionAvailableException
- if no type converters exists to convert to the given type
-
tryConvertTo
default <T> T tryConvertTo(Class<T> type, Object value)
Description copied from interface:TypeConverter
Tries to convert the value to the specified type, returning null if not possible to convert. This method will not throw an exception if an exception occurred during conversion.- Specified by:
tryConvertTo
in interfaceTypeConverter
- Parameters:
type
- the requested typevalue
- the value to be converted- Returns:
- the converted value, or null if not possible to convert
-
tryConvertTo
default <T> T tryConvertTo(Class<T> type, Exchange exchange, Object value)
Description copied from interface:TypeConverter
Tries to convert the value to the specified type in the context of an exchange, returning null if not possible to convert. This method will not throw an exception if an exception occurred during conversion. 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).- Specified by:
tryConvertTo
in interfaceTypeConverter
- Parameters:
type
- the requested typeexchange
- the current exchangevalue
- the value to be converted- Returns:
- the converted value, or null if not possible to convert
-
-