public class DefaultConversionService extends GenericConversionService
GenericConversionService
configured by default
with converters appropriate for most environments.
Designed for direct instantiation but also exposes the static
addDefaultConverters(ConverterRegistry)
utility method for ad-hoc
use against any ConverterRegistry
instance.
Modifier and Type | Class and Description |
---|---|
private static class |
DefaultConversionService.Jsr310ConverterRegistrar
Inner class to avoid a hard-coded dependency on Java 8's
java.time package. |
Modifier and Type | Field and Description |
---|---|
private static boolean |
javaUtilOptionalClassAvailable
Java 8's java.util.Optional class available?
|
private static boolean |
jsr310Available
Java 8's java.time package available?
|
private static DefaultConversionService |
sharedInstance |
private static boolean |
streamAvailable
Java 8's java.util.stream.Stream class available?
|
Constructor and Description |
---|
DefaultConversionService()
Create a new
DefaultConversionService with the set of
default converters. |
Modifier and Type | Method and Description |
---|---|
static void |
addCollectionConverters(ConverterRegistry converterRegistry)
Add common collection converters.
|
static void |
addDefaultConverters(ConverterRegistry converterRegistry)
Add converters appropriate for most environments.
|
private static void |
addScalarConverters(ConverterRegistry converterRegistry) |
static ConversionService |
getSharedInstance()
Return a shared default
ConversionService instance,
lazily building it once needed. |
addConverter, addConverter, addConverter, addConverterFactory, canBypassConvert, canConvert, canConvert, convert, convert, convert, convertNullSource, getConverter, getDefaultConverter, removeConvertible, toString
private static final boolean javaUtilOptionalClassAvailable
private static final boolean jsr310Available
private static final boolean streamAvailable
private static volatile DefaultConversionService sharedInstance
public DefaultConversionService()
DefaultConversionService
with the set of
default converters.public static ConversionService getSharedInstance()
ConversionService
instance,
lazily building it once needed.
NOTE: We highly recommend constructing individual
ConversionService
instances for customization purposes.
This accessor is only meant as a fallback for code paths which
need simple type coercion but cannot access a longer-lived
ConversionService
instance any other way.
ConversionService
instance (never null
)public static void addDefaultConverters(ConverterRegistry converterRegistry)
converterRegistry
- the registry of converters to add to
(must also be castable to ConversionService, e.g. being a ConfigurableConversionService
)java.lang.ClassCastException
- if the given ConverterRegistry could not be cast to a ConversionServicepublic static void addCollectionConverters(ConverterRegistry converterRegistry)
converterRegistry
- the registry of converters to add to
(must also be castable to ConversionService, e.g. being a ConfigurableConversionService
)java.lang.ClassCastException
- if the given ConverterRegistry could not be cast to a ConversionServiceprivate static void addScalarConverters(ConverterRegistry converterRegistry)