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
-
-
Field Summary
Fields Modifier and Type Field Description static String
DISCRIMINATOR_INDEX_PROPERTY
Name of the list property which will hold all indexed discriminator valuesstatic String
DISCRIMINATOR_PROPERTY
Name of the out-of-band discriminator property in a PropertyContainer
-
Constructor Summary
Constructors Constructor Description ClassTranslator(Class<P> declaredClass, CreateContext ctx, Path path)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyMetadata<P>
getKeyMetadata()
Only works on @Entity classesP
loadSafe(com.google.cloud.datastore.Value<com.google.cloud.datastore.FullEntity<?>> container, LoadContext ctx, Path path)
Implement this, returning a proper translated valuevoid
registerSubclass(ClassTranslator<? extends P> translator)
Register a subclass translator with this class translator.com.google.cloud.datastore.Value<com.google.cloud.datastore.FullEntity<?>>
saveSafe(P pojo, boolean index, SaveContext ctx, Path path)
Implement this, returning a proper translated value-
Methods inherited from class com.googlecode.objectify.impl.translate.NullSafeTranslator
load, save
-
-
-
-
Field Detail
-
DISCRIMINATOR_PROPERTY
public static final String DISCRIMINATOR_PROPERTY
Name of the out-of-band discriminator property in a PropertyContainer- See Also:
- Constant Field Values
-
DISCRIMINATOR_INDEX_PROPERTY
public static final String DISCRIMINATOR_INDEX_PROPERTY
Name of the list property which will hold all indexed discriminator values- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ClassTranslator
public ClassTranslator(Class<P> declaredClass, CreateContext ctx, Path path)
-
-
Method Detail
-
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 classNullSafeTranslator<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 classNullSafeTranslator<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
-
-