@Override public ResponseT get() throws ExecutionException, InterruptedException { return (ResponseT) pollingFuture.get().getResponse(); }
@Override public String apply(OperationSnapshot operationSnapshot) { return (String) operationSnapshot.getResponse(); } }
@Override public String apply(OperationSnapshot operationSnapshot) { return (String) operationSnapshot.getResponse(); } };
@Override public ResponseT get() throws ExecutionException { if (completedSnapshot.getErrorCode().getCode().equals(StatusCode.Code.OK)) { return (ResponseT) completedSnapshot.getResponse(); } throw new ExecutionException( new ApiException(null, completedSnapshot.getErrorCode(), false)); }
@Override public ResponseT get() throws ExecutionException { if (completedSnapshot.getErrorCode().getCode().equals(StatusCode.Code.OK)) { return (ResponseT) completedSnapshot.getResponse(); } throw new ExecutionException( new ApiException(null, completedSnapshot.getErrorCode(), false)); }
@Override public Color apply(OperationSnapshot operationSnapshot) { if (!operationSnapshot.getErrorCode().getCode().equals(StatusCode.Code.OK)) { throw ApiExceptionFactory.createException( "Operation with name \"" + operationSnapshot.getName() + "\" failed with status = " + operationSnapshot.getErrorCode() + " and message = " + operationSnapshot.getErrorMessage(), null, operationSnapshot.getErrorCode(), false); } if (operationSnapshot.getResponse() == null) { return null; } if (!(operationSnapshot.getResponse() instanceof Color)) { String errorMessage = "type mismatch: expected " + Color.class.getName() + ", found " + operationSnapshot.getResponse().getClass().getName(); throw new ApiException(errorMessage, null, FakeStatusCode.of(StatusCode.Code.OK), false); } else { return (Color) operationSnapshot.getResponse(); } } }
@Override public ResponseT apply(OperationSnapshot operationSnapshot) { if (!operationSnapshot.getErrorCode().getCode().equals(Code.OK)) { throw ApiExceptionFactory.createException( "Operation with name \"" + operationSnapshot.getName() + "\" failed with status = " + operationSnapshot.getErrorCode() + " and message = " + operationSnapshot.getErrorMessage(), null, operationSnapshot.getErrorCode(), false); } try { return transformer.apply((Any) operationSnapshot.getResponse()); } catch (RuntimeException e) { throw ApiExceptionFactory.createException( "Operation with name \"" + operationSnapshot.getName() + "\" succeeded, but encountered a problem unpacking it.", e, operationSnapshot.getErrorCode(), false); } }
@Override public ResponseT apply(OperationSnapshot operationSnapshot) { if (!operationSnapshot.getErrorCode().getCode().equals(Code.OK)) { throw ApiExceptionFactory.createException( "Operation with name \"" + operationSnapshot.getName() + "\" failed with status = " + operationSnapshot.getErrorCode() + " and message = " + operationSnapshot.getErrorMessage(), null, operationSnapshot.getErrorCode(), false); } try { return transformer.apply((Any) operationSnapshot.getResponse()); } catch (RuntimeException e) { throw ApiExceptionFactory.createException( "Operation with name \"" + operationSnapshot.getName() + "\" succeeded, but encountered a problem unpacking it.", e, operationSnapshot.getErrorCode(), false); } }