public interface Translator<T>
A translator knows how convert between POJO objects and the EntityNode tree structure that Objectify can persist. In principle, this is similar to how a JSON object mapper works. Each node in the object graph corresponds to a node in the EntityNode graph.
Translators are composed of other translators; through a chain of these a whole entity object is assembled or disassembled.
Modifier and Type | Method and Description |
---|---|
T |
load(Node node,
LoadContext ctx)
Loads the content of the specified node, returning the pojo equivalent.
|
Node |
save(T pojo,
Path path,
boolean index,
SaveContext ctx)
Translates the pojo into an EntityNode format.
|
T load(Node node, LoadContext ctx) throws SkipException
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.
node
- is the part of the entity tree we are transforming.ctx
- holds state information during an entity load.SkipException
- if the subtree should not be loaded into a containing entityLoadEngine
Node save(T pojo, Path path, boolean index, SaveContext ctx) throws SkipException
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 valuesSkipException
- if this subtree should not be saved.Copyright © 2014. All rights reserved.