java.util.function.Supplier.get()方法的使用及代码示例

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

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

Supplier.get介绍

[英]Gets a result.
[中]得到一个结果。

代码示例

代码示例来源:origin: jooby-project/jooby

/**
 * Creates a new EventBus using the given factory.
 *
 * @param factory EventBus factory.
 */
public EventBusby(@Nonnull Supplier<EventBus> factory) {
 this(c -> factory.get());
}

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

@Override
public void bulk( @Nonnull Consumer<Logger> consumer )
{
  requireNonNull( consumer, "consumer must not be null" );
  PrintWriter writer;
  synchronized ( lock )
  {
    writer = writerSupplier.get();
    consumer.accept( getBulkLogger( writer, lock ) );
  }
  maybeFlush( writer );
}

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

@Override
  public void bulk( @Nonnull Consumer<Log> consumer )
  {
    PrintWriter writer;
    synchronized ( this )
    {
      writer = writerSupplier.get();
      consumer.accept( new ConsistencyReportLog( Suppliers.singleton( writer ), lock, false ) );
    }
  }
}

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

@Override
public void log( @Nonnull String message )
{
  requireNonNull( message, "message must not be null" );
  PrintWriter writer;
  synchronized ( lock )
  {
    writer = writerSupplier.get();
    writeLog( writer, message );
  }
  maybeFlush( writer );
}

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

@Override
public void bulk( @Nonnull Consumer<Log> consumer )
{
  PrintWriter writer;
  synchronized ( lock )
  {
    writer = writerSupplier.get();
    consumer.accept( new FormattedLog( Suppliers.singleton( writer ), zoneId,
        lock, category, levelRef.get(), false ) );
  }
  if ( autoFlush )
  {
    writer.flush();
  }
}

代码示例来源:origin: jooby-project/jooby

/**
 * Runs the callback function if the current env matches the given name.
 *
 * @param name A name to test for.
 * @param fn A callback function.
 * @param <T> A resulting type.
 * @return A resulting object.
 */
@Nonnull
default <T> Optional<T> ifMode(final String name, final Supplier<T> fn) {
 if (name().equals(name)) {
  return Optional.of(fn.get());
 }
 return Optional.empty();
}

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

@Override
public void log( @Nonnull String format, @Nullable Object... arguments )
{
  requireNonNull( format, "format must not be null" );
  if ( arguments == null || arguments.length == 0 )
  {
    log( format );
    return;
  }
  String message = String.format( format, arguments );
  PrintWriter writer;
  synchronized ( lock )
  {
    writer = writerSupplier.get();
    writeLog( writer, message );
  }
  maybeFlush( writer );
}

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

@Override
public void log( @Nonnull String message, @Nonnull Throwable throwable )
{
  requireNonNull( message, "message must not be null" );
  if ( throwable == null )
  {
    log( message );
    return;
  }
  PrintWriter writer;
  synchronized ( lock )
  {
    writer = writerSupplier.get();
    writeLog( writer, message, throwable );
  }
  maybeFlush( writer );
}

代码示例来源:origin: com.github.ben-manes.caffeine/caffeine

/**
 * Enables the accumulation of {@link CacheStats} during the operation of the cache. Without this
 * {@link Cache#stats} will return zero for all statistics. Note that recording statistics
 * requires bookkeeping to be performed with each operation, and thus imposes a performance
 * penalty on cache operation. Any exception thrown by the supplied {@link StatsCounter} will be
 * suppressed and logged.
 *
 * @param statsCounterSupplier a supplier instance that returns a new {@link StatsCounter}
 * @return this builder instance
 */
@Nonnull
public Caffeine<K, V> recordStats(
  @Nonnull Supplier<? extends StatsCounter> statsCounterSupplier) {
 requireState(this.statsCounterSupplier == null, "Statistics recording was already set");
 requireNonNull(statsCounterSupplier);
 this.statsCounterSupplier = () -> StatsCounter.guardedStatsCounter(statsCounterSupplier.get());
 return this;
}

代码示例来源:origin: com.github.bloodshura/shurax

public static void fill(@Nonnull boolean[] object, @Nonnull Supplier<Boolean> supplier) {
  for (int i = 0, len = object.length; i < len; i++) {
    object[i] = supplier.get();
  }
}

代码示例来源:origin: com.github.bloodshura/shurax

public static void fill(@Nonnull double[] object, @Nonnull Supplier<Double> supplier) {
  for (int i = 0, len = object.length; i < len; i++) {
    object[i] = supplier.get();
  }
}

代码示例来源:origin: com.github.bloodshura/ignitium-core

public static void fill(@Nonnull boolean[] object, @Nonnull Supplier<Boolean> supplier) {
  for (int i = 0, len = object.length; i < len; i++) {
    object[i] = supplier.get();
  }
}

代码示例来源:origin: com.github.bloodshura/ignitium-core

public static void fill(@Nonnull double[] object, @Nonnull Supplier<Double> supplier) {
  for (int i = 0, len = object.length; i < len; i++) {
    object[i] = supplier.get();
  }
}

代码示例来源:origin: com.github.bloodshura/ignitium-core

public static <E> void fill(@Nonnull E[] object, @Nonnull Supplier<E> supplier) {
  for (int i = 0, len = object.length; i < len; i++) {
    object[i] = supplier.get();
  }
}

代码示例来源:origin: com.github.bloodshura/ignitium-core

public static void fill(@Nonnull float[] object, @Nonnull Supplier<Float> supplier) {
  for (int i = 0, len = object.length; i < len; i++) {
    object[i] = supplier.get();
  }
}

代码示例来源:origin: com.github.bloodshura/shurax

public static <E> void fill(@Nonnull E[] object, @Nonnull Supplier<E> supplier) {
  for (int i = 0, len = object.length; i < len; i++) {
    object[i] = supplier.get();
  }
}

代码示例来源:origin: com.github.bloodshura/shurax

public static void fill(@Nonnull int[] object, @Nonnull Supplier<Integer> supplier) {
  for (int i = 0, len = object.length; i < len; i++) {
    object[i] = supplier.get();
  }
}

代码示例来源:origin: com.github.bloodshura/ignitium-core

public static void fill(@Nonnull int[] object, @Nonnull Supplier<Integer> supplier) {
  for (int i = 0, len = object.length; i < len; i++) {
    object[i] = supplier.get();
  }
}

代码示例来源:origin: com.simiacryptus/mindseye-research

/**
 * Sets line search factory.
 *
 * @param lineSearchFactory the line search factory
 * @return the line search factory
 */
@Nonnull
public RoundRobinTrainer setLineSearchFactory(@Nonnull final Supplier<LineSearchStrategy> lineSearchFactory) {
 this.lineSearchFactory = s -> lineSearchFactory.get();
 return this;
}

代码示例来源:origin: org.codehaus.griffon/griffon-javafx

@Nonnull
  private static DoubleSupplier resolveDoubleSupplier(@Nonnull final Supplier<? extends Number> supplier) {
    requireNonNull(supplier, ERROR_SUPPLIER_NULL);
    return () -> supplier.get().doubleValue();
  }
}

相关文章

Supplier类方法