java.util.stream.Stream.noneMatch()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(683)

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

Stream.noneMatch介绍

[英]Returns whether no elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the stream is empty then true is returned and the predicate is not evaluated.

This is a short-circuiting terminal operation.
[中]返回此流的元素是否与提供的谓词匹配。如果不需要确定结果,则不能对所有元素的谓词求值。如果流为空,则返回true,并且不计算谓词。
这是一个short-circuiting terminal operation

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Any partial matches for "methods" and "consumes"?
 */
public boolean hasConsumesMismatch() {
  return this.partialMatches.stream().
      noneMatch(PartialMatch::hasConsumesMatch);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Any partial matches for "methods", "consumes", "produces", and "params"?
 */
public boolean hasParamsMismatch() {
  return this.partialMatches.stream().
      noneMatch(PartialMatch::hasParamsMatch);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Any partial matches for "methods"?
 */
public boolean hasMethodsMismatch() {
  return this.partialMatches.stream().
      noneMatch(PartialMatch::hasMethodsMatch);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Any partial matches for "methods", "consumes", and "produces"?
 */
public boolean hasProducesMismatch() {
  return this.partialMatches.stream().
      noneMatch(PartialMatch::hasProducesMatch);
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Same as {@link #regenerateTokenFromLegacy(Secret)} but only applied if there is an existing legacy token. 
 * <p>
 * Otherwise, no effect.
 */
public synchronized void regenerateTokenFromLegacyIfRequired(@Nonnull Secret newLegacyApiToken) {
  if(tokenList.stream().noneMatch(HashedToken::isLegacy)){
    deleteAllLegacyAndGenerateNewOne(newLegacyApiToken, true);
  }
}

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

/**
 * Checks whether all of generic type arguments are immutable.
 * If at least one argument is mutable, we assume that the whole list of type arguments
 * is mutable.
 * @param typeArgsClassNames type arguments class names.
 * @return true if all of generic type arguments are immutable.
 */
private boolean areImmutableTypeArguments(List<String> typeArgsClassNames) {
  return typeArgsClassNames.stream().noneMatch(
    typeName -> {
      return !immutableClassShortNames.contains(typeName)
        && !immutableClassCanonicalNames.contains(typeName);
    });
}

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

@Override
public Request authenticate(Route route, Response response)
{
  // skip if we already tried or were not asked for Kerberos
  if (response.request().headers(AUTHORIZATION).stream().anyMatch(SpnegoHandler::isNegotiate) ||
      response.headers(WWW_AUTHENTICATE).stream().noneMatch(SpnegoHandler::isNegotiate)) {
    return null;
  }
  return authenticate(response.request());
}

代码示例来源:origin: SonarSource/sonarqube

public static BadRequestException create(List<String> errorMessages) {
 checkArgument(!errorMessages.isEmpty(), "At least one error message is required");
 checkArgument(errorMessages.stream().noneMatch(message -> message == null || message.isEmpty()), "Message cannot be empty");
 return new BadRequestException(errorMessages);
}

代码示例来源:origin: apache/geode

static void addMaxHeap(final List<String> commandLine, final String maxHeap) {
 if (StringUtils.isNotBlank(maxHeap)) {
  commandLine.add("-Xmx" + maxHeap);
  String collectorKey = "-XX:+UseConcMarkSweepGC";
  if (!commandLine.contains(collectorKey)) {
   commandLine.add(collectorKey);
  }
  String occupancyFractionKey = "-XX:CMSInitiatingOccupancyFraction=";
  if (commandLine.stream().noneMatch(s -> s.contains(occupancyFractionKey))) {
   commandLine.add(occupancyFractionKey + CMS_INITIAL_OCCUPANCY_FRACTION);
  }
 }
}

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

private static void verifyUsingG1Gc()
{
  try {
    List<String> garbageCollectors = ManagementFactory.getGarbageCollectorMXBeans().stream()
        .map(GarbageCollectorMXBean::getName)
        .collect(toImmutableList());
    if (garbageCollectors.stream().noneMatch(name -> name.toUpperCase(Locale.US).startsWith("G1 "))) {
      warnRequirement("Current garbage collectors are %s. Presto recommends the G1 garbage collector.", garbageCollectors);
    }
  }
  catch (RuntimeException e) {
    // This should never happen since we have verified the OS and JVM above
    failRequirement("Cannot read garbage collector information: %s", e);
  }
}

代码示例来源:origin: spring-cloud/spring-cloud-sleuth

private Consumer<List<ExchangeFilterFunction>> addTraceExchangeFilterFunctionIfNotPresent() {
  return functions -> {
    if (functions.stream()
        .noneMatch(f -> f instanceof TraceExchangeFilterFunction)) {
      functions.add(new TraceExchangeFilterFunction(this.beanFactory));
    }
  };
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Install or remove an {@link ExecutorChannelInterceptor} that invokes a
 * completion task once the message is handled.
 * @param channel the channel to configure
 * @param preservePublishOrder whether preserve order is on or off based on
 * which an interceptor is either added or removed.
 */
static void configureOutboundChannel(MessageChannel channel, boolean preservePublishOrder) {
  if (preservePublishOrder) {
    Assert.isInstanceOf(ExecutorSubscribableChannel.class, channel,
        "An ExecutorSubscribableChannel is required for `preservePublishOrder`");
    ExecutorSubscribableChannel execChannel = (ExecutorSubscribableChannel) channel;
    if (execChannel.getInterceptors().stream().noneMatch(i -> i instanceof CallbackInterceptor)) {
      execChannel.addInterceptor(0, new CallbackInterceptor());
    }
  }
  else if (channel instanceof ExecutorSubscribableChannel) {
    ExecutorSubscribableChannel execChannel = (ExecutorSubscribableChannel) channel;
    execChannel.getInterceptors().stream().filter(i -> i instanceof CallbackInterceptor)
        .findFirst()
        .map(execChannel::removeInterceptor);
  }
}

代码示例来源:origin: skylot/jadx

public static ApkSignature getApkSignature(JadxWrapper wrapper) {
  // Only show the ApkSignature node if an AndroidManifest.xml is present.
  // Without a manifest the Google ApkVerifier refuses to work.
  if (wrapper.getResources().stream().noneMatch(r -> "AndroidManifest.xml".equals(r.getName()))) {
    return null;
  }
  File openFile = wrapper.getOpenFile();
  return new ApkSignature(openFile);
}

代码示例来源:origin: SonarSource/sonarqube

private static List<BuiltInQProfile> toQualityProfiles(List<BuiltInQProfile.Builder> builders) {
  if (builders.stream().noneMatch(BuiltInQProfile.Builder::isDeclaredDefault)) {
   Optional<BuiltInQProfile.Builder> sonarWayProfile = builders.stream().filter(builder -> builder.getName().equals(DEFAULT_PROFILE_NAME)).findFirst();
   if (sonarWayProfile.isPresent()) {
    sonarWayProfile.get().setComputedDefault(true);
   } else {
    builders.iterator().next().setComputedDefault(true);
   }
  }
  return builders.stream()
   .map(BuiltInQProfile.Builder::build)
   .collect(MoreCollectors.toList(builders.size()));
 }
}

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

private boolean isInliningCandidate(Expression expression, ProjectNode node)
{
  // TryExpressions should not be pushed down. However they are now being handled as lambda
  // passed to a FunctionCall now and should not affect predicate push down. So we want to make
  // sure the conjuncts are not TryExpressions.
  verify(AstUtils.preOrder(expression).noneMatch(TryExpression.class::isInstance));
  // candidate symbols for inlining are
  //   1. references to simple constants
  //   2. references to complex expressions that appear only once
  // which come from the node, as opposed to an enclosing scope.
  Set<Symbol> childOutputSet = ImmutableSet.copyOf(node.getOutputSymbols());
  Map<Symbol, Long> dependencies = SymbolsExtractor.extractAll(expression).stream()
      .filter(childOutputSet::contains)
      .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
  return dependencies.entrySet().stream()
      .allMatch(entry -> entry.getValue() == 1 || node.getAssignments().get(entry.getKey()) instanceof Literal);
}

代码示例来源:origin: confluentinc/ksql

private void executeStatements(final String queries) {
 final List<PreparedStatement<?>> preparedStatements =
   ksqlEngine.parseStatements(queries);
 if (failOnNoQueries) {
  final boolean noQueries = preparedStatements.stream()
    .map(PreparedStatement::getStatement)
    .noneMatch(stmt -> stmt instanceof QueryContainer);
  if (noQueries) {
   throw new KsqlException("The SQL file did not contain any queries");
  }
 }
 preparedStatements.forEach(this::executeStatement);
}

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

private ActualProperties deriveProperties(PlanNode result, List<ActualProperties> inputProperties)
{
  // TODO: move this logic to PlanSanityChecker once PropertyDerivations.deriveProperties fully supports local exchanges
  ActualProperties outputProperties = PropertyDerivations.deriveProperties(result, inputProperties, metadata, session, types, parser);
  verify(result instanceof SemiJoinNode || inputProperties.stream().noneMatch(ActualProperties::isNullsAndAnyReplicated) || outputProperties.isNullsAndAnyReplicated(),
      "SemiJoinNode is the only node that can strip null replication");
  return outputProperties;
}

代码示例来源:origin: goldmansachs/gs-collections

@Benchmark
public void short_circuit_middle_serial_lazy_jdk()
{
  Assert.assertFalse(this.integersJDK.stream().noneMatch(each -> each > SIZE / 2));
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Return true if this Resource is selected.
 * @param r the Resource to check.
 * @return whether the Resource was selected.
 */
public boolean isSelected(Resource r) {
  return getResourceSelectors().stream().noneMatch(s -> s.isSelected(r));
}

代码示例来源:origin: goldmansachs/gs-collections

@Benchmark
public void process_none_serial_lazy_jdk()
{
  Assert.assertTrue(this.integersJDK.stream().noneMatch(each -> each < 0));
}

相关文章