当前位置: 首页>>代码示例>>Java>>正文


Java Supplier.get方法代码示例

本文整理汇总了Java中com.google.common.base.Supplier.get方法的典型用法代码示例。如果您正苦于以下问题:Java Supplier.get方法的具体用法?Java Supplier.get怎么用?Java Supplier.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.base.Supplier的用法示例。


在下文中一共展示了Supplier.get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: waitFor

import com.google.common.base.Supplier; //导入方法依赖的package包/类
public static void waitFor(Supplier<Boolean> check,
    int checkEveryMillis, int waitForMillis)
    throws TimeoutException, InterruptedException
{
  long st = Time.now();
  do {
    boolean result = check.get();
    if (result) {
      return;
    }
    
    Thread.sleep(checkEveryMillis);
  } while (Time.now() - st < waitForMillis);
  
  throw new TimeoutException("Timed out waiting for condition. " +
      "Thread diagnostics:\n" +
      TimedOutTestsListener.buildThreadDiagnosticString());
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:19,代码来源:GenericTestUtils.java

示例2: getInstance

import com.google.common.base.Supplier; //导入方法依赖的package包/类
static <T extends Completable> T getInstance(Class<T> type, Supplier<T> supplier) {
  ClassToInstanceMap<Completable> components = state().components;
  @Nullable T instance = components.getInstance(type);
  if (instance == null) {
    instance = supplier.get();
    components.putInstance(type, instance);
  }
  return instance;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:StaticEnvironment.java

示例3: CompactStriped

import com.google.common.base.Supplier; //导入方法依赖的package包/类
private CompactStriped(int stripes, Supplier<L> supplier) {
  super(stripes);
  Preconditions.checkArgument(stripes <= Ints.MAX_POWER_OF_TWO, "Stripes must be <= 2^30)");

  this.array = new Object[mask + 1];
  for (int i = 0; i < array.length; i++) {
    array[i] = supplier.get();
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:10,代码来源:Striped.java

示例4: assertChecksum

import com.google.common.base.Supplier; //导入方法依赖的package包/类
private static void assertChecksum(Supplier<Checksum> supplier, String input) {
  byte[] bytes = HashTestUtils.ascii(input);

  Checksum checksum = supplier.get();
  checksum.update(bytes, 0, bytes.length);
  long value = checksum.getValue();

  String toString = "name";
  HashFunction func = new ChecksumHashFunction(supplier, 32, toString);
  assertEquals(toString, func.toString());
  assertEquals(value, func.hashBytes(bytes).padToLong());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:13,代码来源:ChecksumHashFunctionTest.java

示例5: waitFor

import com.google.common.base.Supplier; //导入方法依赖的package包/类
/**
 * Wait for <code>check</code> to return true for each
 * <code>checkEveryMillis</code> ms. In the main loop, this method will log
 * the message "waiting in main loop" for each <code>logInterval</code> times
 * iteration to confirm the thread is alive.
 * @param check user defined checker
 * @param checkEveryMillis interval to call <code>check</code>
 * @param logInterval interval to log for each
 */
public void waitFor(Supplier<Boolean> check, int checkEveryMillis,
    int logInterval) throws InterruptedException {
  Preconditions.checkNotNull(check, "check should not be null");
  Preconditions.checkArgument(checkEveryMillis >= 0,
      "checkEveryMillis should be positive value");
  Preconditions.checkArgument(logInterval >= 0,
      "logInterval should be positive value");

  int loggingCounter = logInterval;
  do {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Check the condition for main loop.");
    }

    boolean result = check.get();
    if (result) {
      LOG.info("Exits the main loop.");
      return;
    }
    if (--loggingCounter <= 0) {
      LOG.info("Waiting in main loop.");
      loggingCounter = logInterval;
    }

    Thread.sleep(checkEveryMillis);
  } while (true);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:37,代码来源:AMRMClient.java

示例6: registerType

import com.google.common.base.Supplier; //导入方法依赖的package包/类
public static void registerType(String type, Supplier<Identifier> constructor) {
    if (constructor == null) throw new NullPointerException("constructor");
    if (constructor.get() == null) throw new NullPointerException("constructor.get()");
    registeredIdentifiers.put(type, constructor);
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:6,代码来源:Identifier.java

示例7: MapDbAppStorage

import com.google.common.base.Supplier; //导入方法依赖的package包/类
protected MapDbAppStorage(String fileSystemName, Supplier<DB> db) {
    this.fileSystemName = Objects.requireNonNull(fileSystemName);
    this.db = db.get();

    rootNodeVar = this.db.atomicVar("rootNode", NodeInfoSerializer.INSTANCE)
            .createOrOpen();

    childNodesMap = this.db
            .hashMap("childNodes", UuidSerializer.INSTANCE, UuidListSerializer.INSTANCE)
            .createOrOpen();

    childNodeMap = this.db
            .hashMap("childNode", NamedLinkSerializer.INSTANCE, UuidSerializer.INSTANCE)
            .createOrOpen();

    parentNodeMap = this.db
            .hashMap("parentNode", UuidSerializer.INSTANCE, UuidSerializer.INSTANCE)
            .createOrOpen();

    nodeInfoMap = this.db
            .hashMap("nodeInfo", UuidSerializer.INSTANCE, NodeInfoSerializer.INSTANCE)
            .createOrOpen();

    dataMap = this.db
            .hashMap("data", NamedLinkSerializer.INSTANCE, Serializer.BYTE_ARRAY)
            .createOrOpen();

    dataNamesMap = this.db
            .hashMap("dataNames", UuidSerializer.INSTANCE, StringSetSerializer.INSTANCE)
            .createOrOpen();

    timeSeriesNamesMap = this.db
            .hashMap("timeSeriesNamesMap", UuidSerializer.INSTANCE, StringSetSerializer.INSTANCE)
            .createOrOpen();

    timeSeriesMetadataMap = this.db
            .hashMap("timeSeriesMetadataMap", NamedLinkSerializer.INSTANCE, TimeSeriesMetadataSerializer.INSTANCE)
            .createOrOpen();

    timeSeriesLastChunkMap = this.db
            .hashMap("timeSeriesLastChunkMap", TimeSeriesKeySerializer.INSTANCE, Serializer.INTEGER)
            .createOrOpen();

    doubleTimeSeriesChunksMap = this.db
            .hashMap("doubleTimeSeriesChunksMap", TimeSeriesChunkKeySerializer.INSTANCE, DoubleArrayChunkSerializer.INSTANCE)
            .createOrOpen();

    stringTimeSeriesChunksMap = this.db
            .hashMap("stringTimeSeriesChunksMap", TimeSeriesChunkKeySerializer.INSTANCE, StringArrayChunkSerializer.INSTANCE)
            .createOrOpen();

    dependencyNodesMap = this.db
            .hashMap("dependencyNodes", UuidSerializer.INSTANCE, NamedLinkListSerializer.INSTANCE)
            .createOrOpen();

    dependencyNodesByNameMap = this.db
            .hashMap("dependencyNodesByName", NamedLinkSerializer.INSTANCE, UuidListSerializer.INSTANCE)
            .createOrOpen();

    backwardDependencyNodesMap = this.db
            .hashMap("backwardDependencyNodes", UuidSerializer.INSTANCE, UuidListSerializer.INSTANCE)
            .createOrOpen();
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:64,代码来源:MapDbAppStorage.java

示例8: content

import com.google.common.base.Supplier; //导入方法依赖的package包/类
@GET
@Path("content")
public Response content(
        @QueryParam("r") String repositoryName,
        @QueryParam("g") String groupId,
        @QueryParam("a") String artifactId,
        @QueryParam("v") String version,
        @QueryParam("c") String classifier,
        @QueryParam("p") @DefaultValue("jar") String extension
) {


    // default version
    if ("LATEST".equals(version)) {
        version = null;
    }
    version = Optional.ofNullable(version).orElse(latestVersion(
            repositoryName, groupId, artifactId, classifier, extension
    ));

    // valid params
    if (isBlank(repositoryName) || isBlank(groupId) || isBlank(artifactId) || isBlank(version)) {
        return NOT_FOUND;
    }

    Repository repository = repositoryManager.get(repositoryName);
    if (null == repository || !repository.getFormat().getValue().equals("maven2")) {
        return NOT_FOUND;
    }

    StorageFacet facet = repository.facet(StorageFacet.class);
    Supplier<StorageTx> storageTxSupplier = facet.txSupplier();

    log.debug("rundeck download repository: {}", repository);
    final StorageTx tx = storageTxSupplier.get();
    tx.begin();
    Bucket bucket = tx.findBucket(repository);
    log.debug("rundeck download bucket: {}", bucket);

    if (null == bucket) {
        return commitAndReturn(NOT_FOUND, tx);
    }

    String fileName = artifactId + "-" + version + (isBlank(classifier) ? "" : ("-" + classifier)) + "." + extension;
    String path = groupId.replace(".", "/") +
            "/" + artifactId +
            "/" + version +
            "/" + fileName;
    Asset asset = tx.findAssetWithProperty("name", path, bucket);
    log.debug("rundeck download asset: {}", asset);
    if (null == asset) {
        return commitAndReturn(NOT_FOUND, tx);
    }
    asset.markAsDownloaded();
    tx.saveAsset(asset);
    Blob blob = tx.requireBlob(asset.requireBlobRef());
    Response.ResponseBuilder ok = Response.ok(blob.getInputStream());
    ok.header("Content-Type", blob.getHeaders().get("BlobStore.content-type"));
    ok.header("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
    return commitAndReturn(ok.build(), tx);
}
 
开发者ID:nongfenqi,项目名称:nexus3-rundeck-plugin,代码行数:62,代码来源:RundeckMavenResource.java


注:本文中的com.google.common.base.Supplier.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。