All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.objectify.impl.translate.ValueTranslatorFactory Maven / Gradle / Ivy

There is a newer version: 6.1.2
Show newest version
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 pojoType;
	
	/** */
	protected ValueTranslatorFactory(Class 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 - 2024 Weber Informatics LLC | Privacy Policy