|
Spring Data Document | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.data.mongodb.core.convert.DefaultTypeMapper
public class DefaultTypeMapper
Default implementation of TypeMapper
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.
Field Summary | |
---|---|
static String |
DEFAULT_TYPE_KEY
|
Constructor Summary | |
---|---|
DefaultTypeMapper()
|
Method Summary | |
---|---|
protected org.springframework.data.util.TypeInformation<?> |
getTypeInformation(String value)
Returns the TypeInformation that shall be used when the given String value is found as type hint. |
protected String |
getTypeString(org.springframework.data.util.TypeInformation<?> typeInformation)
Turn the given type information into the String representation that shall be stored inside the DBObject . |
boolean |
isTypeKey(String key)
Returns whether the given key is the key being used as type key. |
org.springframework.data.util.TypeInformation<?> |
readType(DBObject dbObject)
Reads the TypeInformation from the given DBObject . |
void |
setTypeKey(String typeKey)
Sets the key to store the type information under. |
void |
writeType(Class<?> type,
DBObject dbObject)
Writes type information for the given type into the given DBObject . |
void |
writeType(org.springframework.data.util.TypeInformation<?> info,
DBObject dbObject)
Writes type information for the given TypeInformation into the given DBObject . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_TYPE_KEY
Constructor Detail |
---|
public DefaultTypeMapper()
Method Detail |
---|
public void setTypeKey(String typeKey)
typeKey
- the typeKey to setpublic boolean isTypeKey(String key)
TypeMapper
isTypeKey
in interface TypeMapper
public org.springframework.data.util.TypeInformation<?> readType(DBObject dbObject)
TypeMapper
TypeInformation
from the given DBObject
.
readType
in interface TypeMapper
dbObject
- must not be null.
public void writeType(Class<?> type, DBObject dbObject)
TypeMapper
DBObject
.
writeType
in interface TypeMapper
type
- must not be null.dbObject
- must not be null.public void writeType(org.springframework.data.util.TypeInformation<?> info, DBObject dbObject)
TypeMapper
TypeInformation
into the given DBObject
.
writeType
in interface TypeMapper
info
- must not be null.dbObject
- must not be null.protected String getTypeString(org.springframework.data.util.TypeInformation<?> typeInformation)
DBObject
. If
the returned String is null no type information will be stored. Default implementation simply returns
the fully-qualified class name.
typeInformation
- must not be null.
protected org.springframework.data.util.TypeInformation<?> getTypeInformation(String value)
TypeInformation
that shall be used when the given String
value is found as type hint.
The default implementation will simply interpret the given value as fully-qualified class name and try to load the
class. Will return null in case the given String
is empty. Will not be called in case no
String
was found for the configured type key at all.
value
- the type to load, must not be null.
String
representation or null if nothing found or the
class cannot be loaded.
|
Spring Data Document | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |