Java Code Examples for com.google.common.util.concurrent.FluentFuture#from()
The following examples show how to use
com.google.common.util.concurrent.FluentFuture#from() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProxyResource.java From presto with Apache License 2.0 | 4 votes |
private FluentFuture<ProxyResponse> executeHttp(Request request) { return FluentFuture.from(httpClient.executeAsync(request, new ProxyResponseHandler())); }
Example 2
Source File: CheckedValue.java From yangtools with Eclipse Public License 1.0 | 2 votes |
/** * Transform this object into an immediately-completed {@link FluentFuture}. The future will be successful * if this object has a contained value or unsuccessful if this objects contains an exception. * * @return A {@link FluentFuture}. */ public final FluentFuture<T> toFluentFuture() { return FluentFuture.from(isFirst() ? Futures.immediateFuture(first()) : Futures.immediateFailedFuture(second())); }
Example 3
Source File: FluentFutures.java From yangtools with Eclipse Public License 1.0 | 2 votes |
/** * Return a {@link FluentFuture} which is immediately failed, reporting specified failure {@code cause}. * * @param cause failure cause * @return An immediately-failed FluentFuture. * @throws NullPointerException if {@code cause} is null */ public static <T> FluentFuture<T> immediateFailedFluentFuture(final Throwable cause) { return FluentFuture.from(Futures.immediateFailedFuture(requireNonNull(cause))); }
Example 4
Source File: FluentFutures.java From yangtools with Eclipse Public License 1.0 | 2 votes |
/** * Return a {@link FluentFuture} which is immediately completed, reporting specified {@code result}. * * @param result result of the future * @return An immediately-completed FluentFuture. * @throws NullPointerException if {@code result} is null */ public static <T> FluentFuture<T> immediateFluentFuture(final T result) { return FluentFuture.from(Futures.immediateFuture(requireNonNull(result))); }
Example 5
Source File: RpcResultBuilder.java From yangtools with Eclipse Public License 1.0 | 2 votes |
/** * Builds RpcResult and wraps it in a Future. * * <p> * This is a convenience method to assist those writing RPCs that produce immediate results. It allows you to * replace {@code FluentFuture.from(Futures.immediateFuture(rpcResult.build()))} with * {@code rpcResult.buildFuture()} * * @return Future for RpcResult built by RpcResultBuilder */ public @NonNull FluentFuture<RpcResult<T>> buildFuture() { return FluentFuture.from(Futures.immediateFuture(build())); }