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 Details

    • 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 Details

    • Registrar

      public Registrar(ObjectifyFactory fact)
      Parameters:
      fact - is so that the translations can be obtained
  • Method Details

    • 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