public class Registrar extends Object
Maintains information about registered entity classes
There logic here is convoluted by polymorphic hierarchies. Entity classes can be registered in any particular order, requiring some considerable care.
Modifier and Type | Field and Description |
---|---|
protected Map<String,EntityMetadata<?>> |
byKind
This maps kind to EntityMetadata
|
protected boolean |
cacheEnabled
True if any @Cached entities have been registered
|
protected ObjectifyFactory |
fact
Needed to obtain the converters
|
Constructor and Description |
---|
Registrar(ObjectifyFactory fact) |
Modifier and Type | Method and Description |
---|---|
<T> EntityMetadata<T> |
getMetadata(Class<T> clazz) |
<T> EntityMetadata<T> |
getMetadata(String kind) |
<T> EntityMetadata<T> |
getMetadataSafe(Class<T> clazz) |
<T> EntityMetadata<T> |
getMetadataSafe(String kind)
Gets metadata for the specified kind
|
boolean |
isCacheEnabled() |
<T> void |
register(Class<T> clazz)
All @Entity and @Subclass classes (for both entity and embedded classes)
must be registered before using Objectify to load or save data.
|
protected ObjectifyFactory fact
protected Map<String,EntityMetadata<?>> byKind
protected boolean cacheEnabled
public Registrar(ObjectifyFactory fact)
fact
- is so that the translations can be obtainedpublic boolean isCacheEnabled()
public <T> void register(Class<T> clazz)
All @Entity and @Subclass classes (for both entity and embedded classes) must be registered before using Objectify to load or save data. This method must be called in a single-threaded mode sometime around application initialization.
Re-registering a class has no effect.
clazz
- must be annotated with either @Entity or @Subclasspublic <T> EntityMetadata<T> getMetadata(String kind)
public <T> EntityMetadata<T> getMetadata(Class<T> clazz)
public <T> EntityMetadata<T> getMetadataSafe(String kind) throws IllegalArgumentException
IllegalArgumentException
- if the kind has not been registeredpublic <T> EntityMetadata<T> getMetadataSafe(Class<T> clazz) throws IllegalArgumentException
IllegalArgumentException
- if the kind has not been registeredCopyright © 2016. All rights reserved.