public abstract class ValueTranslator<P,D> extends NullSafeTranslator<P,D>
Helper which helps take a mapnode's property value and converts it from datastore representation to pojo representation. Note that null checking has already been done.
Constructor and Description |
---|
ValueTranslator(Class<D> datastoreClass) |
Modifier and Type | Method and Description |
---|---|
protected P |
loadSafe(D value,
LoadContext ctx,
Path path)
Implement this, returning a proper translated value
|
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.
|
load, save
protected final P loadSafe(D value, LoadContext ctx, Path path) throws SkipException
NullSafeTranslator
loadSafe
in class NullSafeTranslator<P,D>
value
- will never be nullSkipException
protected 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, that has already been tested forSkipException
- if this field subtree should be skippedprotected abstract D saveValue(P value, boolean index, SaveContext ctx, Path path) throws SkipException
value
- will not be null, that has already been tested forSkipException
- if this subtree should be skippedCopyright © 2014. All rights reserved.