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.
Constructor and Description |
---|
ValueTranslator(Class<D> datastoreClass) |
ValueTranslator(Class<D> datastoreClass,
Class<? extends D> projectionClass)
Sometimes the projection class is more specific than the datastore class
|
Modifier and Type | Method and Description |
---|---|
protected 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 value
|
protected abstract D |
saveValue(P value,
boolean index,
SaveContext ctx,
Path path)
Encode from a normal pojo value to a format that the datastore understands.
|
loadSafe
load, save
protected final P loadSafe2(D value, LoadContext ctx, Path path) throws SkipException
ProjectionSafeTranslator
loadSafe2
in class ProjectionSafeTranslator<P,D>
value
- will not be null and will not be RawValueSkipException
- if this field subtree should be skippedprotected final 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(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 D saveValue(P value, boolean index, SaveContext ctx, Path path) throws SkipException
value
- will not be nullSkipException
- if this subtree should be skippedCopyright © 2016. All rights reserved.