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

x33g5p2x  于2022-01-25 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(212)

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

Predicate.negate介绍

[英]Returns a predicate that represents the logical negation of this predicate.
[中]返回一个谓词,该谓词表示该谓词的逻辑否定。

代码示例

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

@Override
public Predicate<T> negate() {
  return this.delegate.negate();
}

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

@Override
public Predicate<T> negate() {
  return this.delegate.negate();
}

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

@Restricted(NoExternalUse.class) // Jelly use
public List<String> getOriginalDependencyErrors() {
  Predicate<Map.Entry<String, Boolean>> p = Map.Entry::getValue;
  return dependencyErrors.entrySet().stream().filter(p.negate()).map(Map.Entry::getKey).collect(Collectors.toList());
}

代码示例来源:origin: Graylog2/graylog2-server

private void checkUnknownParameters(Map<String, ValueReference> parameters, Set<String> contentPackParameterNames) {
  final Predicate<String> containsContentPackParameter = contentPackParameterNames::contains;
  final Set<String> unknownParameters = parameters.keySet().stream()
      .filter(containsContentPackParameter.negate())
      .collect(Collectors.toSet());
  if (!unknownParameters.isEmpty()) {
    // Ignore unknown parameters for now
    LOG.debug("Unknown parameters: {}", unknownParameters);
  }
}

代码示例来源:origin: siacs/Conversations

@Override
public final byte[] get(final Object key) {
  return Optional.ofNullable(key).map(Object::toString).filter(((Predicate<String>) String::isEmpty).negate()).map(cacheDirectory::resolve).filter(Files::isReadable).map(file -> {
    try {
      return Files.readAllBytes(file);
    } catch (IOException e) {
      throw new UncheckedIOException(e);
    }
  }).orElse(null);
}

代码示例来源:origin: Graylog2/graylog2-server

private void checkMissingParameters(Map<String, ValueReference> parameters, Set<String> contentPackParameterNames) {
    final Predicate<String> containsParameter = parameters::containsKey;
    final Set<String> missingParameters = contentPackParameterNames.stream()
        .filter(containsParameter.negate())
        .collect(Collectors.toSet());
    if (!missingParameters.isEmpty()) {
      throw new MissingParametersException(missingParameters);
    }
  }
}

代码示例来源:origin: vavr-io/vavr

@Override
default BitSet<T> dropUntil(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  return dropWhile(predicate.negate());
}

代码示例来源:origin: vavr-io/vavr

@Override
default Iterator<T> reject(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  return filter(predicate.negate());
}

代码示例来源:origin: vavr-io/vavr

@Override
public Array<T> dropWhile(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  return dropUntil(predicate.negate());
}

代码示例来源:origin: vavr-io/vavr

@Override
public Array<T> takeWhile(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  return takeUntil(predicate.negate());
}

代码示例来源:origin: vavr-io/vavr

@Override
public CharSeq takeRightWhile(Predicate<? super Character> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  return takeRightUntil(predicate.negate());
}

代码示例来源:origin: vavr-io/vavr

@Override
default Iterator<T> dropUntil(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  return dropWhile(predicate.negate());
}

代码示例来源:origin: vavr-io/vavr

@Override
public Array<T> dropRightWhile(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  return dropRightUntil(predicate.negate());
}

代码示例来源:origin: vavr-io/vavr

@Override
default int indexWhere(Predicate<? super T> predicate, int from) {
  Objects.requireNonNull(predicate, "predicate is null");
  int start = Math.max(from, 0);
  int n = start + segmentLength(predicate.negate(), start);
  return (n >= length()) ? -1 : n;
}

代码示例来源:origin: vavr-io/vavr

@SuppressWarnings("unchecked")
static <C extends Traversable<T>, T> C reject(C source, Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  if (source.isEmpty()) {
    return source;
  } else {
    return (C) source.filter(predicate.negate());
  }
}

代码示例来源:origin: org.assertj/assertj-core

public <E> void assertAllMatch(AssertionInfo info, Iterable<? extends E> actual, Predicate<? super E> predicate,
                PredicateDescription predicateDescription) {
 assertNotNull(info, actual);
 predicates.assertIsNotNull(predicate);
 List<? extends E> nonMatches = stream(actual).filter(predicate.negate()).collect(toList());
 if (!nonMatches.isEmpty()) {
  throw failures.failure(info, elementsShouldMatch(actual,
                           nonMatches.size() == 1 ? nonMatches.get(0) : nonMatches,
                           predicateDescription));
 }
}

代码示例来源:origin: Graylog2/graylog2-server

@JsonProperty("reason")
  @Override
  public String toString() {
    final Predicate<ParameterDescriptor> optional = ParameterDescriptor::optional;
    return "Expected " + function.descriptor().params().stream().filter(optional.negate()).count() +
        " arguments but found " + argCount +
        " in call to function " + function.descriptor().name()
        + positionString();
  }
}

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

@Override
public Expression visitProject(ProjectNode node, Void context)
{
  // TODO: add simple algebraic solver for projection translation (right now only considers identity projections)
  Expression underlyingPredicate = node.getSource().accept(this, context);
  List<Expression> projectionEqualities = node.getAssignments().entrySet().stream()
      .filter(SYMBOL_MATCHES_EXPRESSION.negate())
      .map(ENTRY_TO_EQUALITY)
      .collect(toImmutableList());
  return pullExpressionThroughSymbols(combineConjuncts(
      ImmutableList.<Expression>builder()
          .addAll(projectionEqualities)
          .add(underlyingPredicate)
          .build()),
      node.getOutputSymbols());
}

代码示例来源:origin: vavr-io/vavr

@Override
public Tuple2<Array<T>, Array<T>> splitAt(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  final Array<T> init = takeWhile(predicate.negate());
  return Tuple.of(init, drop(init.length()));
}

代码示例来源:origin: vavr-io/vavr

@Override
default Tuple2<Iterator<T>, Iterator<T>> partition(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  if (!hasNext()) {
    return Tuple.of(empty(), empty());
  } else {
    final Stream<T> that = Stream.ofAll(this);
    final Iterator<T> first = that.iterator().filter(predicate);
    final Iterator<T> second = that.iterator().filter(predicate.negate());
    return Tuple.of(first, second);
  }
}

相关文章