public abstract class ValueTranslator<P,D> extends NullSafeTranslator<P,D>
Translator that should be extended for typical atomic values. Does a little bit of expected type checking and handles indexing for us.
Constructor and Description |
---|
ValueTranslator(com.google.cloud.datastore.ValueType... expectedValueTypes) |
Modifier and Type | Method and Description |
---|---|
protected P |
loadSafe(com.google.cloud.datastore.Value<D> value,
LoadContext ctx,
Path path)
Implement this, returning a proper translated value
|
protected 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 com.google.cloud.datastore.Value<D> |
saveSafe(P pojo,
boolean index,
SaveContext ctx,
Path path)
Implement this, returning a proper translated value
|
protected 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.
|
load, save
public ValueTranslator(com.google.cloud.datastore.ValueType... expectedValueTypes)
protected final P loadSafe(com.google.cloud.datastore.Value<D> value, LoadContext ctx, Path path) throws SkipException
NullSafeTranslator
loadSafe
in class NullSafeTranslator<P,D>
value
- will never be null or NullValueSkipException
protected final com.google.cloud.datastore.Value<D> saveSafe(P pojo, boolean index, SaveContext ctx, Path path) throws SkipException
NullSafeTranslator
saveSafe
in class NullSafeTranslator<P,D>
pojo
- will never be nullSkipException
protected abstract P loadValue(com.google.cloud.datastore.Value<D> value, LoadContext ctx, Path path) throws SkipException
value
- will not be null and will actually be the correct typeSkipException
- if this field subtree should be skippedprotected abstract com.google.cloud.datastore.Value<D> saveValue(P value, SaveContext ctx, Path path) throws SkipException
value
- will not be nullSkipException
- if this subtree should be skippedCopyright © 2017. All rights reserved.