public class DefaultTypeMapper<S> extends Object implements TypeMapper<S>
MongoTypeMapper
allowing configuration of the key to lookup and store type
information in DBObject
. The key defaults to #DEFAULT_TYPE_KEY
. Actual type-to-String
conversion and back is done in #getTypeString(TypeInformation)
or #getTypeInformation(String)
respectively.Constructor and Description |
---|
DefaultTypeMapper(TypeAliasAccessor<S> accessor) |
DefaultTypeMapper(TypeAliasAccessor<S> accessor,
List<? extends TypeInformationMapper> mappers) |
DefaultTypeMapper(TypeAliasAccessor<S> accessor,
MappingContext<? extends PersistentEntity<?,?>,?> mappingContext,
List<? extends TypeInformationMapper> additionalMappers) |
Modifier and Type | Method and Description |
---|---|
protected TypeInformation<?> |
getFallbackTypeFor(S source)
Returns the type fallback
TypeInformation in case none could be extracted from the given source. |
TypeInformation<?> |
readType(S source)
Reads the
TypeInformation from the given source. |
<T> TypeInformation<? extends T> |
readType(S source,
TypeInformation<T> basicType)
Returns the
TypeInformation from the given source if it is a more concrete type than the given default one. |
void |
writeType(Class<?> type,
S dbObject)
Writes type information for the given type into the given sink.
|
void |
writeType(TypeInformation<?> info,
S sink)
Writes type information for the given
TypeInformation into the given sink. |
public DefaultTypeMapper(TypeAliasAccessor<S> accessor)
public DefaultTypeMapper(TypeAliasAccessor<S> accessor, List<? extends TypeInformationMapper> mappers)
public DefaultTypeMapper(TypeAliasAccessor<S> accessor, MappingContext<? extends PersistentEntity<?,?>,?> mappingContext, List<? extends TypeInformationMapper> additionalMappers)
public TypeInformation<?> readType(S source)
TypeMapper
TypeInformation
from the given source.readType
in interface TypeMapper<S>
source
- must not be null.public <T> TypeInformation<? extends T> readType(S source, TypeInformation<T> basicType)
TypeMapper
TypeInformation
from the given source if it is a more concrete type than the given default one.readType
in interface TypeMapper<S>
source
- must not be null.protected TypeInformation<?> getFallbackTypeFor(S source)
TypeInformation
in case none could be extracted from the given source.source
- will never be null.public void writeType(Class<?> type, S dbObject)
TypeMapper
writeType
in interface TypeMapper<S>
type
- must not be null.dbObject
- must not be null.public void writeType(TypeInformation<?> info, S sink)
TypeMapper
TypeInformation
into the given sink.writeType
in interface TypeMapper<S>
info
- must not be null.sink
- must not be null.Copyright © 2012. All Rights Reserved.