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

com.googlecode.objectify.util.ResultTranslator Maven / Gradle / Ivy

There is a newer version: 6.1.2
Show newest version
package com.googlecode.objectify.util;


/**
 * Translates from one arbitrary thing to a Result of another arbitrary thing, caching the value.
 *
 * @author Jeff Schnitzer 
 */
abstract public class ResultTranslator extends ResultCache
{
	private F from;

	public ResultTranslator(F from) {
		this.from = from;
	}

	protected abstract T translate(F from);

	@Override
	public T nowUncached() {
		return translate(from);
	}

	/** We can get away with this because the subclass almost always provides concrete types */
	@Override
	public String toString() {
		if (isExecuted())
			return "ResultTranslator(" + from + " -> " + now() + ")";
		else
			return "ResultTranslator(" + from + ")";
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy