com.googlecode.objectify.util.ResultTranslator 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.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 + ")";
}
}