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
Constructors Constructor Description ValueTranslator(Class<D> datastoreClass)ValueTranslator(Class<D> datastoreClass, Class<? extends D> projectionClass)Sometimes the projection class is more specific than the datastore class
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected PloadSafe2(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 PloadValue(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 DsaveSafe(P pojo, boolean index, SaveContext ctx, Path path)Implement this, returning a proper translated valueprotected abstract DsaveValue(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
-
-
-
-
Method Detail
-
loadSafe2
protected final P loadSafe2(D value, LoadContext ctx, Path path) throws SkipException
Description copied from class:ProjectionSafeTranslatorDecode from a property value as stored in the datastore to a type that will be stored in a pojo.- Specified by:
loadSafe2in 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
protected final D saveSafe(P pojo, boolean index, SaveContext ctx, Path path) throws SkipException
Description copied from class:NullSafeTranslatorImplement this, returning a proper translated value- Specified by:
saveSafein classNullSafeTranslator<P,D>- Parameters:
pojo- will never be null- Throws:
SkipException
-
loadValue
protected abstract P loadValue(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 D saveValue(P value, boolean index, 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
-
-