Class ValueTranslator<P,D>
java.lang.Object
com.googlecode.objectify.impl.translate.NullSafeTranslator<P,D>
com.googlecode.objectify.impl.translate.ProjectionSafeTranslator<P,D>
com.googlecode.objectify.impl.translate.ValueTranslator<P,D>
- All Implemented Interfaces:
Translator<P,D>
public abstract class ValueTranslator<P,D> extends ProjectionSafeTranslator<P,D>
A bit of code that does the required type checking and casting so that we have nice typed methods. Also handles the RawValue case of projection queries. Note that null checking has already been done.
- Author:
- Jeff Schnitzer
-
Constructor Summary
ConstructorDescriptionValueTranslator(Class<D> datastoreClass)
ValueTranslator(Class<D> datastoreClass, Class<? extends D> projectionClass)
Sometimes the projection class is more specific than the datastore class -
Method Summary
Modifier and TypeMethodDescriptionprotected P
loadSafe2(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 abstract P
loadValue(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 D
saveSafe(P pojo, boolean index, SaveContext ctx, Path path)
Implement this, returning a proper translated valueprotected abstract D
saveValue(P value, boolean index, 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.ProjectionSafeTranslator
loadSafe
Methods inherited from class com.googlecode.objectify.impl.translate.NullSafeTranslator
load, save
-
Constructor Details
-
ValueTranslator
-
ValueTranslator
Sometimes the projection class is more specific than the datastore class
-
-
Method Details
-
loadSafe2
Description copied from class:ProjectionSafeTranslator
Decode from a property value as stored in the datastore to a type that will be stored in a pojo.- Specified by:
loadSafe2
in classProjectionSafeTranslator<P,D>
- Parameters:
value
- will not be null and will not be RawValue- 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
-
saveSafe
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
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 D saveValue(P value, boolean index, SaveContext ctx, Path path) throws SkipExceptionEncode 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
-