Class ClassTranslator<P>
java.lang.Object
com.googlecode.objectify.impl.translate.NullSafeTranslator<P,com.google.appengine.api.datastore.PropertyContainer>
com.googlecode.objectify.impl.translate.ClassTranslator<P>
- All Implemented Interfaces:
Translator<P,com.google.appengine.api.datastore.PropertyContainer>
public class ClassTranslator<P> extends NullSafeTranslator<P,com.google.appengine.api.datastore.PropertyContainer>
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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet the creator associated with this class.Get the populator associated with this class.loadSafe(com.google.appengine.api.datastore.PropertyContainer 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.appengine.api.datastore.PropertyContainer
saveSafe(P pojo, boolean index, SaveContext ctx, Path path)
Implement this, returning a proper translated valueMethods inherited from class com.googlecode.objectify.impl.translate.NullSafeTranslator
load, save
-
Field Details
-
DISCRIMINATOR_PROPERTY
Name of the out-of-band discriminator property in a PropertyContainer- See Also:
- Constant Field Values
-
DISCRIMINATOR_INDEX_PROPERTY
Name of the list property which will hold all indexed discriminator values- See Also:
- Constant Field Values
-
-
Constructor Details
-
ClassTranslator
-
-
Method Details
-
getDeclaredClass
- Returns:
- the class we translate
-
getDiscriminator
- Returns:
- the discriminator for this class, or null if this is not a @Subclass
-
getPopulator
Get the populator associated with this class. -
getCreator
Get the creator associated with this class. -
loadSafe
public P loadSafe(com.google.appengine.api.datastore.PropertyContainer container, LoadContext ctx, Path path) throws SkipExceptionDescription copied from class:NullSafeTranslator
Implement this, returning a proper translated value- Specified by:
loadSafe
in classNullSafeTranslator<P,com.google.appengine.api.datastore.PropertyContainer>
- Parameters:
container
- will never be null- Throws:
SkipException
-
saveSafe
public com.google.appengine.api.datastore.PropertyContainer saveSafe(P pojo, boolean index, SaveContext ctx, Path path) throws SkipExceptionDescription copied from class:NullSafeTranslator
Implement this, returning a proper translated value- Specified by:
saveSafe
in classNullSafeTranslator<P,com.google.appengine.api.datastore.PropertyContainer>
- Parameters:
pojo
- will never be null- Throws:
SkipException
-
registerSubclass
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.
-