public abstract void execute();
@SuppressWarnings("unchecked")
private V retrieveResult(Object response) throws ExecutionException {
if (response == null) {
throw new ExecutionException("Execution returned null value",
new NullPointerException());
}
if (response instanceof Exception) {
throw new ExecutionException((Exception) response);
}
Map<Address, Response> mapResult = (Map<Address, Response>) response;
assert mapResult.size() == 1;
for (Entry<Address, Response> e : mapResult.entrySet()) {
if (e.getValue() instanceof SuccessfulResponse) {
return (V) ((SuccessfulResponse) e.getValue()).getResponseValue();
}
}
throw new ExecutionException(new IllegalStateException("Invalid response " + response));
}