com.googlecode.objectify.impl.translate.ValueTranslatorFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of objectify Show documentation
Show all versions of objectify Show documentation
The simplest convenient interface to the Google App Engine datastore
package com.googlecode.objectify.impl.translate;
import com.googlecode.objectify.impl.Path;
import com.googlecode.objectify.repackaged.gentyref.GenericTypeReflector;
/**
* Provides a little boilerplate for translators that work on simple atomic types.
*
* @author Jeff Schnitzer
*/
abstract public class ValueTranslatorFactory implements TranslatorFactory
{
/** */
Class extends P> pojoType;
/** */
protected ValueTranslatorFactory(Class extends P> pojoType) {
this.pojoType = pojoType;
}
@Override
final public Translator
create(TypeKey
tk, CreateContext ctx, Path path) {
if (this.pojoType.isAssignableFrom(GenericTypeReflector.erase(tk.getType()))) {
return createValueTranslator(tk, ctx, path);
} else {
return null;
}
}
/**
* Create a translator, knowing that we have the appropriate type. You don't need to check for type matching.
* @param tk type is guaranteed to erase to something assignable to Class
*/
abstract protected ValueTranslator
createValueTranslator(TypeKey
tk, CreateContext ctx, Path path);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy