io.yawp.repository.FutureObject Maven / Gradle / Ivy
package io.yawp.repository;
import io.yawp.commons.utils.EntityUtils;
import io.yawp.repository.hooks.RepositoryHooks;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import com.google.appengine.api.datastore.Key;
public class FutureObject {
private Repository r;
private Future futureKey;
private T object;
private boolean enableHooks;
public FutureObject(Repository r, Future futureKey, T object, boolean enableHooks) {
this.r = r;
this.futureKey = futureKey;
this.object = object;
this.enableHooks = enableHooks;
}
public T get() {
try {
Key key = futureKey.get();
EntityUtils.setKey(r, object, key);
if (enableHooks) {
RepositoryHooks.afterSave(r, object);
}
return object;
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy