com.google.common.base.Supplier.get()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中com.google.common.base.Supplier.get()方法的一些代码示例,展示了Supplier.get()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Supplier.get()方法的具体详情如下:
包路径:com.google.common.base.Supplier
类名称:Supplier
方法名:get

Supplier.get介绍

[英]Retrieves an instance of the appropriate type. The returned object may or may not be a new instance, depending on the implementation.
[中]检索适当类型的实例。返回的对象可能是新实例,也可能不是新实例,具体取决于实现。

代码示例

代码示例来源:origin: google/guava

@Override
public T or(Supplier<? extends T> supplier) {
 return checkNotNull(
   supplier.get(), "use Optional.orNull() instead of a Supplier that returns null");
}

代码示例来源:origin: google/guava

private Map<C, V> getOrCreate(R rowKey) {
 Map<C, V> map = backingMap.get(rowKey);
 if (map == null) {
  map = factory.get();
  backingMap.put(rowKey, map);
 }
 return map;
}

代码示例来源:origin: apache/incubator-druid

createSequenceNumber(ioConfig.getStartPartitions()
                     .getPartitionSequenceNumberMap()
                     .get(partitionOffsetEntry.getKey())
      )) >= 0
), "Sequence sequences are not compatible with start sequences of task");
       driver.persistAsync(committerSupplier.get()),
       new FutureCallback<Object>()
log.info("Persisting all pending data");
try {
 driver.persist(committerSupplier.get()); // persist pending data
  "Handoff completed for segments %s with metadata[%s].",
  Lists.transform(handedOff.getSegments(), DataSegment::getId),
  Preconditions.checkNotNull(handedOff.getCommitMetadata(), "commitMetadata")
);

代码示例来源:origin: apache/incubator-druid

public static Expr.ObjectBinding withSuppliers(final Map<String, Supplier<Object>> bindings)
 {
  return (String name) -> {
   Supplier<Object> supplier = bindings.get(name);
   return supplier == null ? null : supplier.get();
  };
 }
}

代码示例来源:origin: apache/incubator-druid

if (record.offset() < endOffsets.get(record.partition())) {
    if (record.offset() != nextOffsets.get(record.partition())) {
     if (ioConfig.isSkipOffsetGaps()) {
      log.warn(
      driver.persist(committerSupplier.get());
 driver.persist(committerSupplier.get()); // persist pending data
   ((Map) Preconditions.checkNotNull(commitMetadata, "commitMetadata")).get(METADATA_NEXT_PARTITIONS),
   toolbox.getObjectMapper()
       .getTypeFactory()
  committerSupplier.get(),
  sequenceNames.values()
).get();
  "Published segments %s with metadata[%s].",
  publishedSegmentIds,
  Preconditions.checkNotNull(published.getCommitMetadata(), "commitMetadata")
);
   "Handoff completed for segments %s with metadata[%s]",
   Lists.transform(handedOff.getSegments(), DataSegment::getId),
   Preconditions.checkNotNull(handedOff.getCommitMetadata(), "commitMetadata")
 );

代码示例来源:origin: google/guava

@Override
public V load(Object key) {
 checkNotNull(key);
 return computingSupplier.get();
}

代码示例来源:origin: prestodb/presto

public Set<String> getTableNames(String schema)
{
  requireNonNull(schema, "schema is null");
  Map<String, ExampleTable> tables = schemas.get().get(schema);
  if (tables == null) {
    return ImmutableSet.of();
  }
  return tables.keySet();
}

代码示例来源:origin: com.b2international.snowowl/com.b2international.snowowl.core

/**Returns with the primary terminology component ID for the given terminology argument.*/
public String getPrimaryComponentIdByTerminologyId(final String terminologyId) {
  Preconditions.checkNotNull(terminologyId, "Terminology ID argument cannot be null.");
  return primaryTerminologyComponentSupplier.get().get(terminologyId);
}

代码示例来源:origin: google/guava

CustomSortedSetMultimap(Map<K, Collection<V>> map, Supplier<? extends SortedSet<V>> factory) {
 super(map);
 this.factory = checkNotNull(factory);
 valueComparator = factory.get().comparator();
}

代码示例来源:origin: prestodb/presto

public ExampleTable getTable(String schema, String tableName)
{
  requireNonNull(schema, "schema is null");
  requireNonNull(tableName, "tableName is null");
  Map<String, ExampleTable> tables = schemas.get().get(schema);
  if (tables == null) {
    return null;
  }
  return tables.get(tableName);
}

代码示例来源:origin: jclouds/legacy-jclouds

public URI apply(Object from) {
 Object org = from;
 if (org == null)
   return defaultTasksList.get().getHref();
 try {
   return checkNotNull(orgMap.get().get(org)).getTasksList().getHref();
 } catch (NullPointerException e) {
   throw new NoSuchElementException(org + " not found in " + orgMap.get());
 }
}

代码示例来源:origin: google/j2objc

@Override
public V load(Object key) {
 checkNotNull(key);
 return computingSupplier.get();
}

代码示例来源:origin: wildfly/wildfly

private Map<C, V> getOrCreate(R rowKey) {
 Map<C, V> map = backingMap.get(rowKey);
 if (map == null) {
  map = factory.get();
  backingMap.put(rowKey, map);
 }
 return map;
}

代码示例来源:origin: com.b2international.snowowl/com.b2international.snowowl.core

public ICoreTerminologyInformation getTerminologyInformation(final String terminologyId) {
  if (StringUtils.isEmpty(terminologyId)) {
    return NOOP_TERMINOLOGY_INFORMATION;
  }
  return Preconditions.checkNotNull(registeredTerminologiesSupplier.get().get(terminologyId), "Cannot find registered terminology for ID: " + terminologyId);
}

代码示例来源:origin: google/j2objc

@Override
public T or(Supplier<? extends T> supplier) {
 return checkNotNull(
   supplier.get(), "use Optional.orNull() instead of a Supplier that returns null");
}

代码示例来源:origin: apache/incubator-druid

public List<Rule> getRulesWithDefault(final String dataSource)
 {
  List<Rule> retVal = new ArrayList<>();
  Map<String, List<Rule>> theRules = rules.get();
  if (theRules.get(dataSource) != null) {
   retVal.addAll(theRules.get(dataSource));
  }
  if (theRules.get(config.get().getDefaultRule()) != null) {
   retVal.addAll(theRules.get(config.get().getDefaultRule()));
  }
  return retVal;
 }
}

代码示例来源:origin: org.apache.jclouds.api/vcloud

public URI apply(Object from) {
 Object org = from;
 if (org == null)
   return defaultTasksList.get().getHref();
 try {
   return checkNotNull(orgMap.get().get(org)).getTasksList().getHref();
 } catch (NullPointerException e) {
   throw new NoSuchElementException(org + " not found in " + orgMap.get());
 }
}

代码示例来源:origin: wildfly/wildfly

@Override
public V load(Object key) {
 checkNotNull(key);
 return computingSupplier.get();
}

代码示例来源:origin: spotify/helios

/**
 * Metadata to associate with jobs by default. Currently sets some metadata based upon environment
 * variables set when the CLI command is run.
 */
private Map<String, String> defaultMetadata() {
 final Builder<String, String> builder = ImmutableMap.builder();
 final Map<String, String> envVars = envVarSupplier.get();
 for (final Map.Entry<String, String> entry : DEFAULT_METADATA_ENVVARS.entrySet()) {
  final String envKey = entry.getKey();
  final String metadataKey = entry.getValue();
  final String envValue = envVars.get(envKey);
  if (envValue != null) {
   builder.put(metadataKey, envValue);
  }
 }
 return builder.build();
}

代码示例来源:origin: org.jclouds/jclouds-vcloud

public URI apply(Object from) {
 Object org = from;
 if (org == null)
   return defaultUri;
 try {
   return checkNotNull(orgMap.get().get(org)).getTasksList().getHref();
 } catch (NullPointerException e) {
   throw new NoSuchElementException(org + " not found in " + orgMap.get());
 }
}

相关文章

Supplier类方法