Class ValueTranslator<P,D>
java.lang.Object
com.googlecode.objectify.impl.translate.NullSafeTranslator<P,D>
com.googlecode.objectify.impl.translate.ValueTranslator<P,D>
- All Implemented Interfaces:
Translator<P,
D>
Translator that should be extended for typical atomic values. Does a little bit of expected type checking and handles indexing for us.
- Author:
- Jeff Schnitzer invalid input: '<'[email protected]>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final P
loadSafe
(com.google.cloud.datastore.Value<D> value, LoadContext ctx, Path path) Implement this, returning a proper translated valueprotected abstract P
loadValue
(com.google.cloud.datastore.Value<D> value, LoadContext ctx, Path path) Decode from a property value as stored in the datastore to a type that will be stored in a pojo.protected final com.google.cloud.datastore.Value<D>
saveSafe
(P pojo, boolean index, SaveContext ctx, Path path) Implement this, returning a proper translated valueprotected abstract com.google.cloud.datastore.Value<D>
saveValue
(P value, SaveContext ctx, Path path) Encode from a normal pojo value to a format that the datastore understands.Methods inherited from class com.googlecode.objectify.impl.translate.NullSafeTranslator
load, save
-
Constructor Details
-
ValueTranslator
public ValueTranslator(com.google.cloud.datastore.ValueType... expectedValueTypes)
-
-
Method Details
-
loadSafe
protected final P loadSafe(com.google.cloud.datastore.Value<D> value, LoadContext ctx, Path path) throws SkipException Description copied from class:NullSafeTranslator
Implement this, returning a proper translated value- Specified by:
loadSafe
in classNullSafeTranslator<P,
D> - Parameters:
value
- will never be null or NullValue- Throws:
SkipException
-
saveSafe
protected final com.google.cloud.datastore.Value<D> saveSafe(P pojo, boolean index, SaveContext ctx, Path path) throws SkipException Description copied from class:NullSafeTranslator
Implement this, returning a proper translated value- Specified by:
saveSafe
in classNullSafeTranslator<P,
D> - Parameters:
pojo
- will never be null- Throws:
SkipException
-
loadValue
protected abstract P loadValue(com.google.cloud.datastore.Value<D> value, LoadContext ctx, Path path) throws SkipException Decode from a property value as stored in the datastore to a type that will be stored in a pojo.- Parameters:
value
- will not be null and will actually be the correct type- Returns:
- the format which should be stored in the pojo; a null means store a literal null!
- Throws:
SkipException
- if this field subtree should be skipped
-
saveValue
protected abstract com.google.cloud.datastore.Value<D> saveValue(P value, SaveContext ctx, Path path) throws SkipException Encode from a normal pojo value to a format that the datastore understands. Note that a null return value is a literal instruction to store a null.- Parameters:
value
- will not be null- Returns:
- the format which should be stored in the datastore; null means actually store a null!
- Throws:
SkipException
- if this subtree should be skipped
-