public abstract class AbstractTranslator<T> extends Object implements Translator<T>
Very simple helper for all kinds of translators.
Constructor and Description |
---|
AbstractTranslator() |
Modifier and Type | Method and Description |
---|---|
T |
load(Node node,
LoadContext ctx)
Loads the content of the specified node, returning the pojo equivalent.
|
protected abstract T |
loadAbstract(Node node,
LoadContext ctx)
Implement loading
|
Node |
save(T pojo,
Path path,
boolean index,
SaveContext ctx)
Translates the pojo into an EntityNode format.
|
protected abstract Node |
saveAbstract(T pojo,
Path path,
boolean index,
SaveContext ctx)
Implement saving
|
public final T load(Node node, LoadContext ctx)
Translator
Loads the content of the specified node, returning the pojo equivalent.
There is one special return value: If a Result> is returned, the content of the Result will be used instead, but delayed until ctx.done() is called. This happens at the end of a "round" of load operations and is the magic trick that makes populating entity references work efficiently.
load
in interface Translator<T>
node
- is the part of the entity tree we are transforming.ctx
- holds state information during an entity load.LoadEngine
public final Node save(T pojo, Path path, boolean index, SaveContext ctx)
Translator
save
in interface Translator<T>
pojo
- is an object from the pojo entity graph; possibly the whole graphpath
- is the path that the entitynode will be created with - the path to the pojoindex
- is whether the instruction so far is to index or not index property valuesprotected abstract T loadAbstract(Node node, LoadContext ctx)
protected abstract Node saveAbstract(T pojo, Path path, boolean index, SaveContext ctx)
Copyright © 2014. All rights reserved.