Example usage for com.google.common.util.concurrent Futures immediateFuture

List of usage examples for com.google.common.util.concurrent Futures immediateFuture

Introduction

In this page you can find the example usage for com.google.common.util.concurrent Futures immediateFuture.

Prototype

@CheckReturnValue
public static <V> ListenableFuture<V> immediateFuture(@Nullable V value) 

Source Link

Document

Creates a ListenableFuture which has its value set immediately upon construction.

Usage

From source file:com.osbolab.commons.MoreEithers.java

public static <L, R> ListenableFuture<Either<L, R>> futureRight(R of) {
    return Futures.immediateFuture(Either.<L, R>right(of));
}

From source file:com.facebook.buck.artifact_cache.DummyArtifactCache.java

@Override
public ListenableFuture<Void> store(ArtifactInfo info, BorrowablePath output) {
    storeKey = Iterables.getFirst(info.getRuleKeys(), null);
    return Futures.immediateFuture(null);
}

From source file:io.soliton.time.TimeServer.java

@Override
public ListenableFuture<Time.TimeResponse> getTime(Time.TimeRequest request) {
    DateTimeZone timeZone = DateTimeZone.forID(request.getTimezone());
    DateTime now = new DateTime(timeZone);
    Time.TimeResponse.Builder response = Time.TimeResponse.newBuilder();
    return Futures.immediateFuture(response.setTime(now.getMillis()).build());
}

From source file:com.yahoo.yqlplus.engine.sources.AsyncInsertMovieSource.java

@Insert
public ListenableFuture<Movie> insertMovie(@Set("uuid") @DefaultValue("DEFAULT_UUID") String uuid,
        @Set("title") String title, @Set("category") String category, @Set("prodDate") String prodDate,
        @Set("duration") @DefaultValue("122") Integer duration, @Set("reviews") List<String> reviews,
        @Set("newRelease") @DefaultValue("true") Boolean newRelease,
        @Set("rating") @DefaultValue("0x22") Byte rating, @Set("cast") @DefaultValue("Various") String cast) {
    Movie movie = new Movie(uuid, title, category, prodDate, duration, reviews, newRelease, rating, cast);
    movies.put(uuid, movie);//from   www .  j av a  2s  .  co  m
    return Futures.immediateFuture(movie);
}

From source file:com.facebook.buck.core.build.distributed.synchronization.impl.NoOpRemoteBuildRuleCompletionWaiter.java

@Override
public ListenableFuture<CacheResult> waitForBuildRuleToAppearInCache(BuildRule buildRule,
        Supplier<ListenableFuture<CacheResult>> cacheCheck) {
    return Futures.immediateFuture(CacheResult.ignored());
}

From source file:de.metas.ui.web.vaadin.window.editor.NullEditorListener.java

@Override
public ListenableFuture<Object> requestValue(final PropertyPath propertyPath) {
    final Object value = null;
    return Futures.immediateFuture(value);
}

From source file:odl.example.impl.ExampleImpl.java

@Override
public Future<RpcResult<Void>> addApplication(AddApplicationInput input) {
    LOG.info("Adding application {}", input);

    ApplicationRegistryUtils.getInstance().writeToApplicationRegistry(input);

    SwitchConfigurator.getInstance().send("openflow:1", "openflow:1:2");

    NodeMonitor monitor = new NodeMonitor(db);
    monitor.getNodeFromIpAddress("10.0.0.1");
    monitor.measureNodeStatistics("openflow:1", "openflow:1:2");

    return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
}

From source file:co.cask.cdap.common.conf.InMemoryPropertyStore.java

@Override
public synchronized ListenableFuture<T> set(String name, T property) {
    updateAndNotify(name, property);
    return Futures.immediateFuture(property);
}

From source file:com.facebook.buck.util.network.FakeScribeLogger.java

@Override
public ListenableFuture<Void> log(String category, Iterable<String> lines) {
    synchronized (this) {
        loggedCategoryLines.putAll(category, lines);
        return Futures.immediateFuture(null);
    }//  ww w  .  java  2s  .  c  o m
}

From source file:com.github.projectsandstone.api.event.SandstoneEventFactoryCache.java

public static Future<SandstoneEventFactory> getAsync() {
    if (instance != null) {
        return Futures.immediateFuture(SandstoneEventFactoryCache.instance);
    } else if (async != null) {
        Future<SandstoneEventFactory> asc = async;

        if (asc.isDone()) {
            try {
                instance = asc.get();//  www .  j a  va 2  s  . c  om
            } catch (InterruptedException | ExecutionException e) {
                throw new RethrowException(e);
            }
            async = null;
        }

        return asc;
    } else {
        async = Sandstone.getEventManager().getEventGenerator().createFactoryAsync(SandstoneEventFactory.class);
        return async;
    }
}