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
ConstructorDescriptionDefaultTypeMapper
(TypeAliasAccessor<S> accessor) Creates a newDefaultTypeMapper
using the givenTypeAliasAccessor
.DefaultTypeMapper
(TypeAliasAccessor<S> accessor, List<? extends TypeInformationMapper> mappers) DefaultTypeMapper
(TypeAliasAccessor<S> accessor, MappingContext<? extends PersistentEntity<?, ?>, ?> mappingContext, List<? extends TypeInformationMapper> additionalMappers) Creates a newDefaultTypeMapper
using the givenTypeAliasAccessor
,MappingContext
and additionalTypeInformationMapper
s. -
Method Summary
Modifier and TypeMethodDescriptionprotected final Alias
getAliasFor
(TypeInformation<?> info) Returns the alias to be used for the givenTypeInformation
.protected TypeInformation<?>
getFallbackTypeFor
(S source) Returns the type fallbackTypeInformation
in case none could be extracted from the given source.Reads theTypeInformation
from the given source.<T> TypeInformation<? extends T>
readType
(S source, TypeInformation<T> basicType) Returns theTypeInformation
from the given source if it is a more concrete type than the given default one.void
setBeanClassLoader
(ClassLoader classLoader) void
Writes type information for the given type into the given sink.void
writeType
(TypeInformation<?> info, S sink) Writes type information for the givenTypeInformation
into the given sink.
-
Constructor Details
-
DefaultTypeMapper
Creates a newDefaultTypeMapper
using the givenTypeAliasAccessor
. It will use aSimpleTypeInformationMapper
to 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 newDefaultTypeMapper
using the givenTypeAliasAccessor
,MappingContext
and additionalTypeInformationMapper
s. Will register aMappingContextTypeInformationMapper
before the given additional mappers.- Parameters:
accessor
- must not be null.mappingContext
-additionalMappers
- must not be null.
-
-
Method Details
-
readType
Description copied from interface:TypeMapper
Reads theTypeInformation
from the given source.- Specified by:
readType
in interfaceTypeMapper<S>
- Parameters:
source
- must not be null.- Returns:
-
readType
Description copied from interface:TypeMapper
Returns theTypeInformation
from the given source if it is a more concrete type than the given default one.- Specified by:
readType
in interfaceTypeMapper<S>
- Parameters:
source
- must not be null.basicType
- must not be null.- Returns:
-
getFallbackTypeFor
Returns the type fallbackTypeInformation
in case none could be extracted from the given source.- Parameters:
source
- will never be null.- Returns:
-
writeType
Description copied from interface:TypeMapper
Writes type information for the given type into the given sink.- Specified by:
writeType
in interfaceTypeMapper<S>
- Parameters:
type
- must not be null.dbObject
- must not be null.
-
writeType
Description copied from interface:TypeMapper
Writes type information for the givenTypeInformation
into the given sink.- Specified by:
writeType
in interfaceTypeMapper<S>
- Parameters:
info
- must not be null.sink
- must not be null.
-
setBeanClassLoader
- Specified by:
setBeanClassLoader
in interfaceBeanClassLoaderAware
-
getAliasFor
Returns the alias to be used for the givenTypeInformation
.- Parameters:
info
- must not be null- Returns:
- the alias for the given
TypeInformation
or null of none was found or all mappers returned null.
-