Example usage for com.google.common.util.concurrent Callables returning

List of usage examples for com.google.common.util.concurrent Callables returning

Introduction

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

Prototype

public static <T> Callable<T> returning(@Nullable final T value) 

Source Link

Document

Creates a Callable which immediately returns a preset value each time it is called.

Usage

From source file:com.android.build.gradle.internal.PostCompilationData.java

public void setInputFiles(@Nullable List<File> inputFiles) {
    this.inputFiles = Callables.returning(inputFiles);
}

From source file:de.cosmocode.palava.cache.AbstractComputingCacheService.java

@Override
public final void store(Serializable key, Object value, CacheExpiration expiration) {
    try {/*from   w  w w  .j a  va  2s .  c om*/
        computeAndStore(key, Callables.returning(value), expiration);
    } catch (ExecutionException e) {
        throw new IllegalArgumentException(e.getCause());
    }
}

From source file:com.google.devcoin.utils.Threading.java

/**
 * Put a dummy task into the queue and wait for it to be run. Because it's single threaded, this means all
 * tasks submitted before this point are now completed. Usually you won't want to use this method - it's a
 * convenience primarily used in unit testing. If you want to wait for an event to be called the right thing
 * to do is usually to create a {@link com.google.common.util.concurrent.SettableFuture} and then call set
 * on it. You can then either block on that future, compose it, add listeners to it and so on.
 *///  w  w w  .ja va2 s. c  o  m
public static void waitForUserCode() {
    // If this assert fires it means you have a bug in your code - you can't call this method inside your own
    // event handlers because it would never return. If you aren't calling this method explicitly, then that
    // means there's a bug in bitcoinj.
    if (vUserThread != null) {
        checkState(vUserThread.get() != null && vUserThread.get() != Thread.currentThread(),
                "waitForUserCode() run on user code thread would deadlock.");
    }
    Futures.getUnchecked(USER_THREAD.submit(Callables.returning(null)));
}

From source file:com.google.logicoin.utils.Threading.java

/**
 * Put a dummy task into the queue and wait for it to be run. Because it's single threaded, this means all
 * tasks submitted before this point are now completed. Usually you won't want to use this method - it's a
 * convenience primarily used in unit testing. If you want to wait for an event to be called the right thing
 * to do is usually to create a {@link com.google.common.util.concurrent.SettableFuture} and then call set
 * on it. You can then either block on that future, compose it, add listeners to it and so on.
 *//*from w  ww.  j  av  a  2s.co m*/
public static void waitForUserCode() {
    // If this assert fires it means you have a bug in your code - you can't call this method inside your own
    // event handlers because it would never return. If you aren't calling this method explicitly, then that
    // means there's a bug in logicoinj.
    if (vUserThread != null) {
        checkState(vUserThread.get() != null && vUserThread.get() != Thread.currentThread(),
                "waitForUserCode() run on user code thread would deadlock.");
    }
    Futures.getUnchecked(USER_THREAD.submit(Callables.returning(null)));
}

From source file:com.android.build.gradle.internal.PostCompilationData.java

public void setInputDir(@NonNull File inputDir) {
    this.inputDir = Callables.returning(inputDir);
}

From source file:com.google.digitalcoin.utils.Threading.java

/**
 * Put a dummy task into the queue and wait for it to be run. Because it's single threaded, this means all
 * tasks submitted before this point are now completed. Usually you won't want to use this method - it's a
 * convenience primarily used in unit testing. If you want to wait for an event to be called the right thing
 * to do is usually to create a {@link com.google.common.util.concurrent.SettableFuture} and then call set
 * on it. You can then either block on that future, compose it, add listeners to it and so on.
 *//*  ww w .ja v  a2 s .c om*/
public static void waitForUserCode() {
    // If this assert fires it means you have a bug in your code - you can't call this method inside your own
    // event handlers because it would never return. If you aren't calling this method explicitly, then that
    // means there's a bug in digitalcoinj.
    if (vUserThread != null) {
        checkState(vUserThread.get() != null && vUserThread.get() != Thread.currentThread(),
                "waitForUserCode() run on user code thread would deadlock.");
    }
    Futures.getUnchecked(USER_THREAD.submit(Callables.returning(null)));
}

From source file:com.google.litecoin.utils.Threading.java

/**
 * Put a dummy task into the queue and wait for it to be run. Because it's single threaded, this means all
 * tasks submitted before this point are now completed. Usually you won't want to use this method - it's a
 * convenience primarily used in unit testing. If you want to wait for an event to be called the right thing
 * to do is usually to create a {@link com.google.common.util.concurrent.SettableFuture} and then call set
 * on it. You can then either block on that future, compose it, add listeners to it and so on.
 *//* www. j  ava2s .  c o  m*/
public static void waitForUserCode() {
    // If this assert fires it means you have a bug in your code - you can't call this method inside your own
    // event handlers because it would never return. If you aren't calling this method explicitly, then that
    // means there's a bug in bitcoinj.
    if (vUserThread != null) {
        checkState(vUserThread.get() != null && vUserThread.get() != Thread.currentThread(),
                "waitForUserCode() run on user code thread would deadlock.");
    }
    Futures.getUnchecked(SINGLE_THREADED_EXECUTOR.submit(Callables.returning(null)));
}

From source file:com.android.build.gradle.internal.PostCompilationData.java

public void setJavaResourcesInputDir(@NonNull File javaResourcesInputDir) {
    this.javaResourcesInputDir = Callables.returning(javaResourcesInputDir);
}

From source file:org.gradle.api.plugins.quality.CheckstylePlugin.java

private void configureTaskConventionMapping(Configuration configuration, Checkstyle task) {
    ConventionMapping taskMapping = task.getConventionMapping();
    taskMapping.map("checkstyleClasspath", Callables.returning(configuration));
    taskMapping.map("config", new Callable<TextResource>() {
        @Override//from   w w w  . j  av  a  2s  . c o  m
        public TextResource call() {
            return extension.getConfig();
        }
    });
    taskMapping.map("configProperties", new Callable<Map<String, Object>>() {
        @Override
        public Map<String, Object> call() {
            return extension.getConfigProperties();
        }
    });
    taskMapping.map("ignoreFailures", new Callable<Boolean>() {
        @Override
        public Boolean call() {
            return extension.isIgnoreFailures();
        }
    });
    taskMapping.map("showViolations", new Callable<Boolean>() {
        @Override
        public Boolean call() {
            return extension.isShowViolations();
        }
    });
    taskMapping.map("maxErrors", new Callable<Integer>() {
        @Override
        public Integer call() {
            return extension.getMaxErrors();
        }
    });
    taskMapping.map("maxWarnings", new Callable<Integer>() {
        @Override
        public Integer call() {
            return extension.getMaxWarnings();
        }
    });
}

From source file:org.gradle.api.plugins.quality.JDependPlugin.java

private void configureTaskConventionMapping(Configuration configuration, JDepend task) {
    conventionMappingOf(task).map("jdependClasspath", Callables.returning(configuration));
}