Package com.googlecode.objectify.impl
Class Registrar
- java.lang.Object
-
- com.googlecode.objectify.impl.Registrar
-
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.
- Author:
- Jeff Schnitzer
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,EntityMetadata<?>>
byKind
This maps kind to EntityMetadataprotected boolean
cacheEnabled
True if any @Cached entities have been registeredprotected ObjectifyFactory
fact
Needed to obtain the converters
-
Constructor Summary
Constructors Constructor Description Registrar(ObjectifyFactory fact)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 kindboolean
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.
-
-
-
Field Detail
-
fact
protected ObjectifyFactory fact
Needed to obtain the converters
-
byKind
protected Map<String,EntityMetadata<?>> byKind
This maps kind to EntityMetadata
-
cacheEnabled
protected boolean cacheEnabled
True if any @Cached entities have been registered
-
-
Constructor Detail
-
Registrar
public Registrar(ObjectifyFactory fact)
- Parameters:
fact
- is so that the translations can be obtained
-
-
Method Detail
-
isCacheEnabled
public boolean isCacheEnabled()
- Returns:
- true if any entities are cacheable
-
register
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.
- Parameters:
clazz
- must be annotated with either @Entity or @Subclass
-
getMetadata
public <T> EntityMetadata<T> getMetadata(String kind)
- Returns:
- the metadata for the specified kind, or null if there was nothing appropriate registered
-
getMetadata
public <T> EntityMetadata<T> getMetadata(Class<T> clazz)
- Returns:
- the metadata for the specified class, or null if there was nothing appropriate registered
-
getMetadataSafe
public <T> EntityMetadata<T> getMetadataSafe(String kind) throws IllegalArgumentException
Gets metadata for the specified kind- Throws:
IllegalArgumentException
- if the kind has not been registered
-
getMetadataSafe
public <T> EntityMetadata<T> getMetadataSafe(Class<T> clazz) throws IllegalArgumentException
- Returns:
- the metadata for a kind of typed object
- Throws:
IllegalArgumentException
- if the kind has not been registered
-
-