Class ClassTranslator<P>

java.lang.Object
com.googlecode.objectify.impl.translate.NullSafeTranslator<P,com.google.cloud.datastore.FullEntity<?>>
com.googlecode.objectify.impl.translate.ClassTranslator<P>
All Implemented Interfaces:
Translator<P,com.google.cloud.datastore.FullEntity<?>>

public class ClassTranslator<P> extends NullSafeTranslator<P,com.google.cloud.datastore.FullEntity<?>>

Some common code for Translators which know how to convert a POJO type into a PropertiesContainer. This might be polymorphic; we get polymorphism when @Subclasses are registered on this translator.

Author:
Jeff Schnitzer <[email protected]>
  • Field Details

    • DISCRIMINATOR_PROPERTY

      public static final String DISCRIMINATOR_PROPERTY
      Name of the out-of-band discriminator property in a PropertyContainer
      See Also:
    • DISCRIMINATOR_INDEX_PROPERTY

      public static final String DISCRIMINATOR_INDEX_PROPERTY
      Name of the list property which will hold all indexed discriminator values
      See Also:
  • Constructor Details

  • Method Details

    • loadSafe

      public P loadSafe(com.google.cloud.datastore.Value<com.google.cloud.datastore.FullEntity<?>> container, LoadContext ctx, Path path) throws SkipException
      Description copied from class: NullSafeTranslator
      Implement this, returning a proper translated value
      Specified by:
      loadSafe in class NullSafeTranslator<P,com.google.cloud.datastore.FullEntity<?>>
      Parameters:
      container - will never be null or NullValue
      Throws:
      SkipException
    • saveSafe

      public com.google.cloud.datastore.Value<com.google.cloud.datastore.FullEntity<?>> saveSafe(P pojo, boolean index, SaveContext ctx, Path path) throws SkipException
      Description copied from class: NullSafeTranslator
      Implement this, returning a proper translated value
      Specified by:
      saveSafe in class NullSafeTranslator<P,com.google.cloud.datastore.FullEntity<?>>
      Parameters:
      pojo - will never be null
      Throws:
      SkipException
    • registerSubclass

      public void registerSubclass(ClassTranslator<? extends P> translator)
      Register a subclass translator with this class translator. That way if we get called upon to translate an instance of the subclass, we will forward to the correct translator.
    • getKeyMetadata

      public KeyMetadata<P> getKeyMetadata()
      Only works on @Entity classes