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

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

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

Predicate.and介绍

[英]Returns a composed predicate that represents a short-circuiting logical AND of this predicate and another. When evaluating the composed predicate, if this predicate is false, then the otherpredicate is not evaluated.

Any exceptions thrown during evaluation of either predicate are relayed to the caller; if evaluation of this predicate throws an exception, the other predicate will not be evaluated.
[中]

代码示例

代码示例来源:origin: GoogleContainerTools/jib

/**
 * Adds a filter to the walked paths.
 *
 * @param pathFilter the filter. {@code pathFilter} returns {@code true} if the path should be
 *     accepted and {@code false} otherwise.
 * @return this
 */
public DirectoryWalker filter(Predicate<Path> pathFilter) {
 this.pathFilter = this.pathFilter.and(pathFilter);
 return this;
}

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

@Override
public Predicate<T> and(Predicate<? super T> other) {
  return this.delegate.and(other);
}

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

@Override
public Predicate<T> and(Predicate<? super T> other) {
  return this.delegate.and(other);
}

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

/**
 * Exclude all the databases that the given predicate tests as true for.
 * @param databases the databases to excluded
 * @return
 */
public Builder excludeDatabases(Predicate<String> databases) {
  this.dbFilter = this.dbFilter.and(databases.negate());
  return this;
}

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

/**
 * Exclude all the tables that the given predicate tests as true for.
 * @param tables the tables to be excluded.
 * @return this
 */
public Builder excludeTables(Predicate<TableId> tables) {
  this.tableFilter = this.tableFilter.and(tables.negate());
  return this;
}

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

public Builder and(Predicate<ServerWebExchange> predicate) {
  Assert.notNull(this.predicate, "can not call and() on null predicate");
  this.predicate = this.predicate.and(predicate);
  return this;
}

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

ScoreEntityIterator filter( Predicate<ScoreEntry> predicate )
{
  if ( this.predicate != null )
  {
    predicate = this.predicate.and( predicate );
  }
  return new ScoreEntityIterator( iterator, predicate );
}

代码示例来源:origin: testcontainers/testcontainers-java

private Predicate<Field> isSharedContainer() {
  return isContainer().and(ReflectionUtils::isStatic);
}

代码示例来源:origin: testcontainers/testcontainers-java

private Predicate<Field> isRestartContainer() {
  return isContainer().and(ReflectionUtils::isNotStatic);
}

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

@Test
public void createWithGeneratedDatabaseName() throws Exception {
  Predicate<String> urlPredicate = (url) -> url.startsWith("jdbc:hsqldb:mem:");
  urlPredicate.and((url) -> !url.endsWith("dataSource"));
  urlPredicate.and((url) -> !url.endsWith("shouldBeOverriddenByGeneratedName"));
  assertCorrectSetupForSingleDataSource("jdbc-config-db-name-generated.xml", urlPredicate);
}

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

private void buildErrorRecordingPredicate() {
  this.errorRecordingPredicate =
      getRecordingPredicate()
          .and(buildIgnoreExceptionsPredicate()
              .orElse(DEFAULT_RECORD_FAILURE_PREDICATE));
}

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

private void buildExceptionPredicate() {
  this.exceptionPredicate =
      getRetryPredicate()
          .and(buildIgnoreExceptionsPredicate()
              .orElse(DEFAULT_RECORD_FAILURE_PREDICATE));
}

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

@Override
public Predicate<ServerWebExchange> apply(
    Object unused) {
  return headerPredicate(X_CF_FORWARDED_URL)
      .and(headerPredicate(X_CF_PROXY_SIGNATURE))
      .and(headerPredicate(X_CF_PROXY_METADATA));
}

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

/**
 * A method creates the {@link Predicate} which is able to filter all Jersey meta-providers along with the components which
 * is able to register the current used {@link InjectionManager}.
 *
 * @param injectionManager current injection manager.
 * @return {@code Predicate} excluding Jersey meta-providers and the specific ones for a current {@code InjectionManager}.
 */
public static Predicate<ContractProvider> excludeMetaProviders(InjectionManager injectionManager) {
  return EXCLUDE_META_PROVIDERS.and(model -> !injectionManager.isRegistrable(model.getImplementationClass()));
}

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

/**
 * A method creates the {@link Predicate} which is able to filter all Jersey meta-providers along with the components which
 * is able to register the current used {@link InjectionManager}.
 *
 * @param injectionManager current injection manager.
 * @return {@code Predicate} excluding Jersey meta-providers and the specific ones for a current {@code InjectionManager}.
 */
public static Predicate<ContractProvider> excludeMetaProviders(InjectionManager injectionManager) {
  return EXCLUDE_META_PROVIDERS.and(model -> !injectionManager.isRegistrable(model.getImplementationClass()));
}

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

@Override
public Persister<ENTITY> persister(HasLabelSet<ENTITY> includedFields) {
  Predicate<Column> columns = insertColumnFilter.and(c -> includedFields.test(c.getId()));
  String statement = getInsertStatement(updateColumnFilter.and(c12 -> includedFields.test(c12.getId())));
  return entity -> persist(entity, f -> columns.test(columnsByFields.get(f)), statement);
}

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

@Override
public Updater<ENTITY> updater(HasLabelSet<ENTITY> includedFields) {
  assertHasPrimaryKeyColumns();
  Predicate<Column> columns = updateColumnFilter.and(c -> includedFields.test(c.getId()));
  String statement = getUpdateStatement(updateColumnFilter.and(c12 -> includedFields.test(c12.getId())));
  return entity -> update(entity, f -> columns.test(columnsByFields.get(f)), statement);
}

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

private Set<String> getSessions(Flag... flags) {
  Locality locality = new CacheLocality(this.cache);
  try (Stream<Key<String>> keys = this.cache.getAdvancedCache().withFlags(flags).keySet().stream()) {
    return keys.filter(this.filter.and(key -> locality.isLocal(key))).map(key -> key.getValue()).collect(Collectors.toSet());
  }
}

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

@DataBoundConstructor
public Plugin(String sourceId, JSONObject o) {
  super(sourceId, o, UpdateSite.this.url);
  this.wiki = get(o,"wiki");
  this.title = get(o,"title");
  this.excerpt = get(o,"excerpt");
  this.compatibleSinceVersion = Util.intern(get(o,"compatibleSinceVersion"));
  this.minimumJavaVersion = Util.intern(get(o, "minimumJavaVersion"));
  this.requiredCore = Util.intern(get(o,"requiredCore"));
  this.categories = o.has("labels") ? internInPlace((String[])o.getJSONArray("labels").toArray(EMPTY_STRING_ARRAY)) : null;
  JSONArray ja = o.getJSONArray("dependencies");
  int depCount = (int)(ja.stream().filter(IS_DEP_PREDICATE.and(IS_NOT_OPTIONAL)).count());
  int optionalDepCount = (int)(ja.stream().filter(IS_DEP_PREDICATE.and(IS_NOT_OPTIONAL.negate())).count());
  dependencies = getPresizedMutableMap(depCount);
  optionalDependencies = getPresizedMutableMap(optionalDepCount);
  for(Object jo : o.getJSONArray("dependencies")) {
    JSONObject depObj = (JSONObject) jo;
    // Make sure there's a name attribute and that the optional value isn't true.
    String depName = Util.intern(get(depObj,"name"));
    if (depName!=null) {
      if (get(depObj, "optional").equals("false")) {
        dependencies.put(depName, Util.intern(get(depObj, "version")));
      } else {
        optionalDependencies.put(depName, Util.intern(get(depObj, "version")));
      }
    }
  }
}

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

public static Predicate<MethodInsnNode> mount(final ClassLoader loader, final String owner) {
 Signature use1 = new Signature(loader, owner, "use", Jooby.class);
 Signature use2 = new Signature(loader, owner, "use", String.class
   , Jooby.class);
 return is(MethodInsnNode.class).and(m -> {
  return use1.matches(m) || use2.matches(m);
 });
}

相关文章