public class TranslatorRegistry extends Object
Manages all the translators used to map between POJO fields and the types that the Datastore can actually persist. Essentially acts as an aggregator for all the TranslatorFactory objects.
When Objectify arranges a translator for a type at registration time, it runs through the available TranslatorFactory instances one at time looking for one that will provide a Translator. The first one found is kept and used during runtime assembly and disassembly of entities.
Constructor and Description |
---|
TranslatorRegistry(ObjectifyFactory fact)
Initialize the default set of converters in the proper order.
|
Modifier and Type | Method and Description |
---|---|
void |
add(TranslatorFactory<?> trans)
Add a new translator to the list.
|
void |
addEarly(TranslatorFactory<?> trans)
Add a new translator to the beginning of the list, before all other translators
except other translators that have been added early.
|
<T> Translator<T> |
create(Path path,
Property property,
Type type,
CreateContext ctx)
Goes through our list of known translators and returns the first one that succeeds
|
public TranslatorRegistry(ObjectifyFactory fact)
public void add(TranslatorFactory<?> trans)
Add a new translator to the list. Translators are added in order after most of the "plumbing" translators (collections, arrays, maps, serialize, embeds, references) but before any of the standard value conversions like String, Number, Key, Enum, SqlDate, TimeZone, etc.
Translators are added in-order so earlier translaters pre-empt later translators.
public void addEarly(TranslatorFactory<?> trans)
Add a new translator to the beginning of the list, before all other translators except other translators that have been added early.
public <T> Translator<T> create(Path path, Property property, Type type, CreateContext ctx)
path
- is the path to this type, used for logging and debuggingctx
- is the context we pass down from the rootIllegalStateException
- if no matching loader can be foundCopyright © 2014. All rights reserved.