类 DefaultConversionService
- java.lang.Object
- org.springframework.core.convert.support.GenericConversionService
- org.springframework.core.convert.support.DefaultConversionService
public class DefaultConversionService extends GenericConversionService
A specialization ofGenericConversionService
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 anyConverterRegistry
instance.- 从以下版本开始:
- 3.1
- 作者:
- Chris Beams, Juergen Hoeller, Stephane Nicoll
构造器概要
构造器 构造器 说明 DefaultConversionService()
Create a newDefaultConversionService
with the set of default converters.
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static void
addCollectionConverters(ConverterRegistry converterRegistry)
Add common collection converters.static void
addDefaultConverters(ConverterRegistry converterRegistry)
Add converters appropriate for most environments.static ConversionService
getSharedInstance()
Return a shared defaultConversionService
instance, lazily building it once needed.从类继承的方法 org.springframework.core.convert.support.GenericConversionService
addConverter, addConverter, addConverter, addConverterFactory, canBypassConvert, canConvert, canConvert, convert, convert, convert, convertNullSource, getConverter, getDefaultConverter, removeConvertible, toString
构造器详细资料
DefaultConversionService
public DefaultConversionService()
Create a newDefaultConversionService
with the set of default converters.
方法详细资料
getSharedInstance
public static ConversionService getSharedInstance()
Return a shared defaultConversionService
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-livedConversionService
instance any other way.- 返回:
- the shared
ConversionService
instance (nevernull
) - 从以下版本开始:
- 4.3.5
addDefaultConverters
public static void addDefaultConverters(ConverterRegistry converterRegistry)
Add converters appropriate for most environments.- 参数:
converterRegistry
- the registry of converters to add to (must also be castable to ConversionService, e.g. being aConfigurableConversionService
)- 抛出:
ClassCastException
- if the given ConverterRegistry could not be cast to a ConversionService
addCollectionConverters
public static void addCollectionConverters(ConverterRegistry converterRegistry)
Add common collection converters.- 参数:
converterRegistry
- the registry of converters to add to (must also be castable to ConversionService, e.g. being aConfigurableConversionService
)- 抛出:
ClassCastException
- if the given ConverterRegistry could not be cast to a ConversionService- 从以下版本开始:
- 4.2.3