Class ConfigurableConverter
- All Implemented Interfaces:
Converter
BasicConverter subclass that supports pluggable type conversion discovery via ConversionFinder.
Pass one or more ConversionFinder instances to the constructor. Finders are consulted in order before
falling back to the built-in BasicConverter reflection logic.
Example:
ConfigurableConverter
See Also:
-
Field Summary
Fields inherited from class org.apache.juneau.commons.conversion.BasicConverter
INSTANCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <I,O> Conversion<I, O> findConversion(Class<I> inType, Class<O> outType) Finds a conversion function from the specified input type to the specified output type.booleanhasCustomConversion(Class<?> inType, Class<?> outType) Returnstrue if any registeredConversionFindercan convert the specified type pair.Methods inherited from class org.apache.juneau.commons.conversion.CachingConverter
canConvert, to, to, to, to
-
Constructor Details
-
ConfigurableConverter
Constructor.- Parameters:
finders- OptionalConversionFinderinstances consulted in order before registered type-pair conversions and the built-inBasicConverterreflection logic.
-
-
Method Details
-
hasCustomConversion
Returnstrue if any registeredConversionFindercan convert the specified type pair.This only checks the registered finders, not the built-in
BasicConverterreflection logic.- Parameters:
inType- The input type class.outType- The output type class.- Returns:
true if a finder-provided conversion exists for the specified type pair.
-
findConversion
Description copied from class:CachingConverterFinds a conversion function from the specified input type to the specified output type.This method is called lazily the first time a conversion between a given type pair is requested. The result is cached so subsequent calls for the same type pair bypass this method entirely. When this method returns
null , a sentinel is stored so that unconvertable type pairs are also only evaluated once.Implementations should return
null if no conversion is possible for the given types, which will causeCachingConverter.to(Object, Class)andCachingConverter.to(Object, Type, Type...)to throwInvalidConversionExceptionfor that type pair.- Overrides:
findConversionin classBasicConverter- Type Parameters:
I- The input type.O- The output type.- Parameters:
inType- The runtime class of the input object.outType- The target output class.- Returns:
- A
Conversionfunction, ornull if no conversion is available.
-