private static <V> ApiFuture<V> translate( ApiFuture<V> from, final boolean idempotent, StatusCode.Code... returnNullOn) { final Set<StatusCode.Code> returnNullOnSet; if (returnNullOn.length > 0) { returnNullOnSet = EnumSet.of(returnNullOn[0], returnNullOn); } else { returnNullOnSet = Collections.emptySet(); } return ApiFutures.catching( from, ApiException.class, new ApiFunction<ApiException, V>() { @Override public V apply(ApiException exception) { if (returnNullOnSet.contains(exception.getStatusCode().getCode())) { return null; } throw new LoggingException(exception); } }); }
MoreExecutors.directExecutor()); return ApiFutures.catching( existsFuture, NotFoundException.class,
MoreExecutors.directExecutor()); return ApiFutures.catching( existsFuture, NotFoundException.class,
ApiFutures.catching( innerFuture, Throwable.class, attemptFailedCallback, MoreExecutors.directExecutor());
private static <V> ApiFuture<V> translate( ApiFuture<V> from, final boolean idempotent, StatusCode.Code... returnNullOn) { final Set<StatusCode.Code> returnNullOnSet; if (returnNullOn.length > 0) { returnNullOnSet = EnumSet.of(returnNullOn[0], returnNullOn); } else { returnNullOnSet = Collections.emptySet(); } return ApiFutures.catching( from, ApiException.class, new ApiFunction<ApiException, V>() { @Override public V apply(ApiException exception) { if (returnNullOnSet.contains(exception.getStatusCode().getCode())) { return null; } throw new LoggingException(exception); } }); }
public OperationFutureImpl( RetryingFuture<OperationSnapshot> pollingFuture, ApiFuture<OperationSnapshot> initialFuture, ApiFunction<OperationSnapshot, ResponseT> responseTransformer, ApiFunction<OperationSnapshot, MetadataT> metadataTransformer, ApiFunction<Exception, ResponseT> exceptionTransformer) { this.pollingFuture = checkNotNull(pollingFuture); this.initialFuture = checkNotNull(initialFuture); this.resultFuture = ApiFutures.catching( ApiFutures.transform(pollingFuture, responseTransformer, directExecutor()), Exception.class, exceptionTransformer, directExecutor()); this.metadataTransformer = checkNotNull(metadataTransformer); }
public OperationFutureImpl( RetryingFuture<OperationSnapshot> pollingFuture, ApiFuture<OperationSnapshot> initialFuture, ApiFunction<OperationSnapshot, ResponseT> responseTransformer, ApiFunction<OperationSnapshot, MetadataT> metadataTransformer, ApiFunction<Exception, ResponseT> exceptionTransformer) { this.pollingFuture = checkNotNull(pollingFuture); this.initialFuture = checkNotNull(initialFuture); this.resultFuture = ApiFutures.catching( ApiFutures.transform(pollingFuture, responseTransformer, directExecutor()), Exception.class, exceptionTransformer, directExecutor()); this.metadataTransformer = checkNotNull(metadataTransformer); }
MoreExecutors.directExecutor()); return ApiFutures.catching( existsFuture, NotFoundException.class,
MoreExecutors.directExecutor()); return ApiFutures.catching( existsFuture, NotFoundException.class,
@Override public ApiFuture<UploadMediaItemResponse> futureCall( UploadMediaItemRequest request, ApiCallContext unusedContext) { PhotosLibraryUploadCallable uploadCallable = new PhotosLibraryUploadCallable(request, clientContext, photosLibrarySettings); // Catches exception thrown while uploading, transforms it into a response // and adds a resumeUrl if exists. return ApiFutures.catching( PhotosLibraryUploadApiFuture.create(uploadCallable, clientContext), Throwable.class, new PhotosLibraryUploadExceptionMappingFn(uploadCallable.getAtomicResumeUrl())); }
ApiFutures.catching(innerFuture, Throwable.class, attemptFailedCallback);