public class DefaultMongoTypeMapper extends DefaultTypeMapper<org.bson.conversions.Bson> implements MongoTypeMapper
MongoTypeMapper
allowing configuration of the key to lookup and store type
information in Document
. The key defaults to DEFAULT_TYPE_KEY
. Actual type-to-String
conversion and back is done in #getTypeString(TypeInformation)
or #getTypeInformation(String)
respectively.Modifier and Type | Class and Description |
---|---|
static class |
DefaultMongoTypeMapper.DocumentTypeAliasAccessor
TypeAliasAccessor to store aliases in a Document . |
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_TYPE_KEY |
Constructor and Description |
---|
DefaultMongoTypeMapper() |
DefaultMongoTypeMapper(String typeKey) |
DefaultMongoTypeMapper(String typeKey,
List<? extends TypeInformationMapper> mappers) |
DefaultMongoTypeMapper(String typeKey,
MappingContext<? extends PersistentEntity<?,?>,?> mappingContext) |
Modifier and Type | Method and Description |
---|---|
protected TypeInformation<?> |
getFallbackTypeFor(org.bson.conversions.Bson source) |
boolean |
isTypeKey(String key)
Returns whether the given key is the type key.
|
void |
writeTypeRestrictions(org.bson.Document result,
Set<Class<?>> restrictedTypes)
Writes type restrictions to the given
Document . |
getAliasFor, readType, readType, writeType, writeType
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
readType, readType, writeType, writeType
public static final String DEFAULT_TYPE_KEY
public DefaultMongoTypeMapper()
public DefaultMongoTypeMapper(@Nullable String typeKey, MappingContext<? extends PersistentEntity<?,?>,?> mappingContext)
public DefaultMongoTypeMapper(@Nullable String typeKey, List<? extends TypeInformationMapper> mappers)
public boolean isTypeKey(String key)
MongoTypeMapper
isTypeKey
in interface MongoTypeMapper
public void writeTypeRestrictions(org.bson.Document result, @Nullable Set<Class<?>> restrictedTypes)
MongoTypeMapper
Document
. This usually results in an $in
-clause to be
generated that restricts the type-key (e.g. _class
) to be in the set of type aliases for the given
restrictedTypes
.writeTypeRestrictions
in interface MongoTypeMapper
result
- must not be nullrestrictedTypes
- must not be nullprotected TypeInformation<?> getFallbackTypeFor(org.bson.conversions.Bson source)
getFallbackTypeFor
in class DefaultTypeMapper<org.bson.conversions.Bson>
Copyright © 2011–2020 Pivotal Software, Inc.. All rights reserved.