Package org.springframework.data.convert
Class DefaultTypeMapper<S>
java.lang.Object
org.springframework.data.convert.DefaultTypeMapper<S>
- All Implemented Interfaces:
Aware,BeanClassLoaderAware,TypeMapper<S>
Default implementation of
TypeMapper.- Author:
- Oliver Gierke, Thomas Darimont, Christoph Strobl, Mark Paluch
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultTypeMapper(TypeAliasAccessor<S> accessor) Creates a newDefaultTypeMapperusing the givenTypeAliasAccessor.DefaultTypeMapper(TypeAliasAccessor<S> accessor, List<? extends TypeInformationMapper> mappers) DefaultTypeMapper(TypeAliasAccessor<S> accessor, MappingContext<? extends PersistentEntity<?, ?>, ?> mappingContext, List<? extends TypeInformationMapper> additionalMappers) Creates a newDefaultTypeMapperusing the givenTypeAliasAccessor,MappingContextand additionalTypeInformationMappers. -
Method Summary
Modifier and TypeMethodDescriptionprotected final AliasgetAliasFor(TypeInformation<?> info) Returns the alias to be used for the givenTypeInformation.protected TypeInformation<?>getFallbackTypeFor(S source) Returns the type fallbackTypeInformationin case none could be extracted from the given source.Reads theTypeInformationfrom the given source.<T> TypeInformation<? extends T>readType(S source, TypeInformation<T> basicType) Returns theTypeInformationfrom the given source if it is a more concrete type than the given default one.voidsetBeanClassLoader(ClassLoader classLoader) voidWrites type information for the given type into the given sink.voidwriteType(TypeInformation<?> info, S sink) Writes type information for the givenTypeInformationinto the given sink.
-
Constructor Details
-
DefaultTypeMapper
Creates a newDefaultTypeMapperusing the givenTypeAliasAccessor. It will use aSimpleTypeInformationMapperto calculate type aliases.- Parameters:
accessor- must not be null.
-
DefaultTypeMapper
public DefaultTypeMapper(TypeAliasAccessor<S> accessor, List<? extends TypeInformationMapper> mappers) - Parameters:
accessor- must not be null.mappers- must not be null.
-
DefaultTypeMapper
public DefaultTypeMapper(TypeAliasAccessor<S> accessor, @Nullable MappingContext<? extends PersistentEntity<?, ?>, ?> mappingContext, List<? extends TypeInformationMapper> additionalMappers) Creates a newDefaultTypeMapperusing the givenTypeAliasAccessor,MappingContextand additionalTypeInformationMappers. Will register aMappingContextTypeInformationMapperbefore the given additional mappers.- Parameters:
accessor- must not be null.mappingContext-additionalMappers- must not be null.
-
-
Method Details
-
readType
Description copied from interface:TypeMapperReads theTypeInformationfrom the given source.- Specified by:
readTypein interfaceTypeMapper<S>- Parameters:
source- must not be null.- Returns:
-
readType
Description copied from interface:TypeMapperReturns theTypeInformationfrom the given source if it is a more concrete type than the given default one.- Specified by:
readTypein interfaceTypeMapper<S>- Parameters:
source- must not be null.basicType- must not be null.- Returns:
-
getFallbackTypeFor
Returns the type fallbackTypeInformationin case none could be extracted from the given source.- Parameters:
source- will never be null.- Returns:
-
writeType
Description copied from interface:TypeMapperWrites type information for the given type into the given sink.- Specified by:
writeTypein interfaceTypeMapper<S>- Parameters:
type- must not be null.dbObject- must not be null.
-
writeType
Description copied from interface:TypeMapperWrites type information for the givenTypeInformationinto the given sink.- Specified by:
writeTypein interfaceTypeMapper<S>- Parameters:
info- must not be null.sink- must not be null.
-
setBeanClassLoader
- Specified by:
setBeanClassLoaderin interfaceBeanClassLoaderAware
-
getAliasFor
Returns the alias to be used for the givenTypeInformation.- Parameters:
info- must not be null- Returns:
- the alias for the given
TypeInformationor null of none was found or all mappers returned null.
-