List of usage examples for com.google.common.util.concurrent Futures immediateFuture
@CheckReturnValue public static <V> ListenableFuture<V> immediateFuture(@Nullable V value)
From source file:org.opendaylight.channel.util.RpcReturnUtil.java
public static <T> Future<RpcResult<T>> returnErr(String errMsg) { return Futures.immediateFuture( RpcResultBuilder.<T>failed().withError(RpcError.ErrorType.APPLICATION, errMsg).build()); }
From source file:org.opendaylight.channel.util.RpcReturnUtil.java
public static <T> Future<RpcResult<T>> returnRpcResult(T out) { return Futures.immediateFuture(RpcResultBuilder.<T>success(out).build()); }
From source file:org.opendaylight.coretutorials.hweventsource.sample.Util.java
public static <T> Future<RpcResult<T>> resultRpcSuccessFor(final T output) { final RpcResult<T> result = RpcResultBuilder.success(output).build(); return Futures.immediateFuture(result); }
From source file:producerstest.ResponseProducerModule.java
@Produces static ListenableFuture<String> greeting() { return Futures.immediateFuture("Hello"); }
From source file:producerstest.MultibindingProducerModule.java
@Produces(type = SET) static ListenableFuture<String> futureStr() { return Futures.immediateFuture("foo"); }
From source file:org.thingsboard.rule.engine.util.EntitiesCustomerIdAsyncLoader.java
public static ListenableFuture<CustomerId> findEntityIdAsync(TbContext ctx, EntityId original) { switch (original.getEntityType()) { case CUSTOMER: return Futures.immediateFuture((CustomerId) original); case USER:// w ww. j a va 2 s.co m return getCustomerAsync(ctx.getUserService().findUserByIdAsync(ctx.getTenantId(), (UserId) original)); case ASSET: return getCustomerAsync( ctx.getAssetService().findAssetByIdAsync(ctx.getTenantId(), (AssetId) original)); case DEVICE: return getCustomerAsync( ctx.getDeviceService().findDeviceByIdAsync(ctx.getTenantId(), (DeviceId) original)); default: return Futures.immediateFailedFuture(new TbNodeException("Unexpected original EntityType " + original)); } }
From source file:org.thingsboard.rule.engine.util.EntitiesTenantIdAsyncLoader.java
public static ListenableFuture<TenantId> findEntityIdAsync(TbContext ctx, EntityId original) { switch (original.getEntityType()) { case TENANT://from w ww . j a v a 2 s .c o m return Futures.immediateFuture((TenantId) original); case CUSTOMER: return getTenantAsync( ctx.getCustomerService().findCustomerByIdAsync(ctx.getTenantId(), (CustomerId) original)); case USER: return getTenantAsync(ctx.getUserService().findUserByIdAsync(ctx.getTenantId(), (UserId) original)); case ASSET: return getTenantAsync(ctx.getAssetService().findAssetByIdAsync(ctx.getTenantId(), (AssetId) original)); case DEVICE: return getTenantAsync( ctx.getDeviceService().findDeviceByIdAsync(ctx.getTenantId(), (DeviceId) original)); case ALARM: return getTenantAsync(ctx.getAlarmService().findAlarmByIdAsync(ctx.getTenantId(), (AlarmId) original)); case RULE_CHAIN: return getTenantAsync( ctx.getRuleChainService().findRuleChainByIdAsync(ctx.getTenantId(), (RuleChainId) original)); default: return Futures.immediateFailedFuture(new TbNodeException("Unexpected original EntityType " + original)); } }
From source file:org.robotninjas.concurrent.FluentFutures.java
/** * Create a {FluentFuture} from a static value * * @param value the value/*from ww w . j a v a 2 s . co m*/ * @param <Y> the type of the value * @return a new completed future */ public static <Y> FluentFuture<Y> from(Y value) { return new FluentDecorator<>(Futures.immediateFuture(value)); }
From source file:com.spotify.helios.cli.command.JobStatusFetcher.java
public static Map<JobId, ListenableFuture<JobStatus>> getJobsStatuses(HeliosClient client, Set<JobId> jobIds) throws InterruptedException { final Map<JobId, ListenableFuture<JobStatus>> futures = Maps.newTreeMap(); try {//w w w . j a v a 2s .c o m final Map<JobId, JobStatus> statuses = client.jobStatuses(jobIds).get(); for (final Entry<JobId, JobStatus> entry : statuses.entrySet()) { futures.put(entry.getKey(), Futures.immediateFuture(entry.getValue())); } } catch (final ExecutionException e) { System.err.println("Warning: masters failed batch status fetching. Falling back to" + " slower job status method"); for (final JobId jobId : jobIds) { futures.put(jobId, client.jobStatus(jobId)); } } return futures; }
From source file:producerstest.multibindings.MultibindingProducerModule.java
@Produces @IntoSet static ListenableFuture<String> futureStr() { return Futures.immediateFuture("foo"); }