当前位置: 首页>>代码示例>>Java>>正文


Java Predicate.and方法代码示例

本文整理汇总了Java中java.util.function.Predicate.and方法的典型用法代码示例。如果您正苦于以下问题:Java Predicate.and方法的具体用法?Java Predicate.and怎么用?Java Predicate.and使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.function.Predicate的用法示例。


在下文中一共展示了Predicate.and方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLiteralFilterPredicate

import java.util.function.Predicate; //导入方法依赖的package包/类
/**
 * This function creates a conjunctive predicate from a list of literal {@link QueryPredicate}s.
 *
 * @param queryPredicates the list of literal {@link QueryPredicate}s to form a conjunctive
 * predicate from.
 * @return a {@link Predicate<Integer>} that checks whether a vertex satisfies the predicates.
 */
public static Predicate<Integer> getLiteralFilterPredicate(
    List<QueryPredicate> queryPredicates) {
    Predicate<Integer> result = null;
    for (QueryPredicate queryPredicate : queryPredicates) {
        Predicate<Integer> predicate;
        switch (queryPredicate.getPredicateType()) {
            case IN_CLAUSE_ONLY_LITERALS:
                predicate = getInClauseLiteralOnlyPredicate((InClausePredicate) queryPredicate);
                break;
            case COMPARATIVE_CLAUSE_PROPERTY_KEY_AND_LITERAL_OPERANDS:
                predicate = getComparativeClauseLiteralOnlyPredicate((ComparisonPredicate)
                    queryPredicate);
                break;
            default:
                throw new IllegalArgumentException("The predicate type " + queryPredicate.
                    getPredicateType().name() + " is not supported.");
        }
        if (null == result) {
            result = predicate;
        } else {
            result = result.and(predicate);
        }
    }
    return result;
}
 
开发者ID:graphflow,项目名称:graphflow,代码行数:33,代码来源:LiteralPredicateFactory.java

示例2: maakRecordfilters

import java.util.function.Predicate; //导入方法依赖的package包/类
@Override
public Predicate<MetaRecord> maakRecordfilters(final Berichtgegevens berichtgegevens) {
    Predicate<MetaRecord> predikaat = new MetaRecordAutorisatiePredicate(berichtgegevens);

    if (berichtgegevens.isMutatieberichtMetMeldingVerstrekkingsbeperking()) {
        predikaat = predikaat.and(new ActueelEnIdentificerendMetaRecordPredicate(berichtgegevens.getPersoonslijst().getNuNuBeeld()));
    }

    if (berichtgegevens.getSoortSynchronisatie() == SoortSynchronisatie.VOLLEDIG_BERICHT) {
        predikaat = predikaat.and(VOORKOMEN_LEVERING_MUTATIE_PREDIKAAT);
    }

    if (berichtgegevens.getDatumAanvangMaterielePeriode() != null) {
        predikaat = predikaat.and(HistorieVanafPredikaat.geldigOpEnNa(berichtgegevens.getDatumAanvangMaterielePeriode()));
    }

    if (berichtgegevens.getMaakBerichtPersoon().getHistorieFilterInformatie() != null
            && berichtgegevens.getMaakBerichtPersoon().getHistorieFilterInformatie().getHistorieVorm() != null) {
        predikaat = predikaat.and(new PeilmomentHistorievormPredicate(
                berichtgegevens.getMaakBerichtPersoon().getHistorieFilterInformatie().getPeilmomentMaterieel(),
                berichtgegevens.getMaakBerichtPersoon().getHistorieFilterInformatie().getPeilmomentFormeel(),
                berichtgegevens.getMaakBerichtPersoon().getHistorieFilterInformatie().getHistorieVorm()));
    }
    return predikaat;
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:26,代码来源:MetaRecordFilterFactoryImpl.java

示例3: clusterBroadcastPong

import java.util.function.Predicate; //导入方法依赖的package包/类
public void clusterBroadcastPong(int target) {
    ClusterNode myself = server.myself;
    for (ClusterNode node : server.cluster.nodes.values()) {
        if (node.link == null) continue;
        if (Objects.equals(node, myself)) continue;
        if (NodeStates.nodeInHandshake(node)) continue;
        if (target == CLUSTER_BROADCAST_LOCAL_SLAVES) {
            Predicate<ClusterNode> t = e -> nodeIsSlave(e) && e.master != null;
            t = t.and(e -> Objects.equals(e.master, myself) || Objects.equals(e.master, myself.master));
            if (!t.test(node)) continue;
        }
        clusterSendPing(node.link, CLUSTERMSG_TYPE_PONG);
    }
}
 
开发者ID:leonchen83,项目名称:redis-cluster-watchdog,代码行数:15,代码来源:ClusterMessageManager.java

示例4: clusterStartHandshake

import java.util.function.Predicate; //导入方法依赖的package包/类
public boolean clusterStartHandshake(String ip, int port, int busPort) {
    Predicate<ClusterNode> t = NodeStates::nodeInHandshake;
    t = t.and(e -> e.ip.equalsIgnoreCase(ip) && e.port == port && e.busPort == busPort);
    if (server.cluster.nodes.values().stream().anyMatch(t)) return false; //no handshake.
    ClusterNode node = createClusterNode(null, CLUSTER_NODE_HANDSHAKE | CLUSTER_NODE_MEET);
    node.ip = ip; node.port = port; node.busPort = busPort; clusterAddNode(node); return true;
}
 
开发者ID:leonchen83,项目名称:redis-cluster-watchdog,代码行数:8,代码来源:ClusterNodeManager.java

示例5: getFilterPredicate

import java.util.function.Predicate; //导入方法依赖的package包/类
/**
 * Returns a {@link Predicate<String[]>} which combines a list of {@link QueryPredicate}s
 *
 * @param queryPredicates a list of  {@link QueryPredicate}s which are to be converted to a
 * {@link Predicate<String[]>}
 * @param descriptorIndexMap a map of variables to their index in the
 * property result set created by the {@link Filter} operator. {@link Filter} uses its {@link
 * EdgeOrVertexPropertyDescriptor} list to create the property result set from the {@link
 * MatchQueryOutput}.
 * @return a {@link Predicate<String[]>} instance that will perform the comparisons specified
 * in the {@code queryPredicates}.
 */
public static Predicate<String[]> getFilterPredicate(List<QueryPredicate> queryPredicates,
    Map<String, Integer> descriptorIndexMap) {
    Predicate<String[]> result = null;
    for (QueryPredicate queryPredicate : queryPredicates) {
        Predicate<String[]> predicate;
        switch (queryPredicate.getPredicateType()) {
            case IN_CLAUSE_ONLY_LITERALS:
            case IN_CLAUSE_VARIABLES_AND_LITERALS:
                predicate = getInClausePredicate((InClausePredicate) queryPredicate,
                descriptorIndexMap);
                break;
            case COMPARATIVE_CLAUSE_TWO_PROPERTY_KEY_OPERANDS:
            case COMPARATIVE_CLAUSE_PROPERTY_KEY_AND_LITERAL_OPERANDS:
                 predicate = getComparativeClausePredicate((ComparisonPredicate) queryPredicate,
                    descriptorIndexMap);
                 break;
            default:
                // Should never execute. Every predicate type introduced should be supported.
                throw new IllegalArgumentException("The predicate type " + queryPredicate.
                    getPredicateType().name() + " is not supported.");
        }
        if (null == result) {
            result = predicate;
        } else {
            result = result.and(predicate);
        }
    }
    return result;
}
 
开发者ID:graphflow,项目名称:graphflow,代码行数:42,代码来源:PredicateFactory.java

示例6: main

import java.util.function.Predicate; //导入方法依赖的package包/类
public static void main(String[] args) {
	Predicate<Employee> male = e -> e.getSex() == Sex.MALE;
	Predicate<Employee> female = e -> e.getSex() == Sex.FEMALE;
	Predicate<Employee> ageLessThan30 = e -> e.getAge() < 30;
	Predicate<Employee> salaryLessThan20 = e -> e.getSalary() < 20000;
	Predicate<Employee> salaryGreaterThan25 = e -> e.getSalary() > 25000;
	Predicate<Employee> salaryLessThan20OrGreateThan25 = salaryLessThan20.or(salaryGreaterThan25);

	Predicate<Employee> allMaleSalaryLessThan20 = male.and(salaryLessThan20);
	Predicate<Employee> allMaleAgeLessThan30 = male.and(ageLessThan30);
	Predicate<Employee> allFemaleSalaryGreaterThan25 = female.and(salaryGreaterThan25);

	Predicate<Employee> allMaleSalaryLessThan20OrGreateThan25 = male.and(salaryLessThan20OrGreateThan25);

	List<Employee> employees = EmployeeStub.getEmployees();
	System.out.println("All employees");
	System.out.println(employees);
	System.out.println("\n\n");
	
	System.out.println("All Male Salary less than 20");
	System.out.println(employees.stream().filter(allMaleSalaryLessThan20).collect(Collectors.toList()));
	System.out.println("All male Age less than 30");
	System.out.println(employees.stream().filter(allMaleAgeLessThan30).collect(Collectors.toList()));
	System.out.println("All females salary greater than 25");
	System.out.println(employees.stream().filter(allFemaleSalaryGreaterThan25).collect(Collectors.toList()));
	
	System.out.println("All males salary either less than 20 or greater than 25");
	System.out.println(employees.stream().filter(allMaleSalaryLessThan20OrGreateThan25).collect(Collectors.toList()));
}
 
开发者ID:gauravrmazra,项目名称:gauravbytes,代码行数:30,代码来源:Java8FilteringWithPredicates.java

示例7: getSkillCasters

import java.util.function.Predicate; //导入方法依赖的package包/类
@SafeVarargs
public final List<SkillCaster> getSkillCasters(Predicate<SkillCaster> filter, Predicate<SkillCaster>... filters)
{
	for (Predicate<SkillCaster> additionalFilter : filters)
	{
		filter = filter.and(additionalFilter);
	}
	
	return getSkillCasters().stream().filter(filter).collect(Collectors.toList());
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:11,代码来源:L2Character.java

示例8: getSkillCaster

import java.util.function.Predicate; //导入方法依赖的package包/类
@SafeVarargs
public final SkillCaster getSkillCaster(Predicate<SkillCaster> filter, Predicate<SkillCaster>... filters)
{
	for (Predicate<SkillCaster> additionalFilter : filters)
	{
		filter = filter.and(additionalFilter);
	}
	
	return getSkillCasters().stream().filter(filter).findAny().orElse(null);
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:11,代码来源:L2Character.java

示例9: getSize

import java.util.function.Predicate; //导入方法依赖的package包/类
/**
 * @param filter
 * @param filters
 * @return the quantity of items in the inventory
 */
@SafeVarargs
public final int getSize(Predicate<L2ItemInstance> filter, Predicate<L2ItemInstance>... filters)
{
	for (Predicate<L2ItemInstance> additionalFilter : filters)
	{
		filter = filter.and(additionalFilter);
	}
	return (int) _items.values().stream().filter(filter).count();
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:15,代码来源:ItemContainer.java

示例10: getItems

import java.util.function.Predicate; //导入方法依赖的package包/类
/**
 * Gets the items in inventory filtered by filter.
 * @param filter the filter
 * @param filters multiple filters
 * @return the filtered items in inventory
 */
@SafeVarargs
public final Collection<L2ItemInstance> getItems(Predicate<L2ItemInstance> filter, Predicate<L2ItemInstance>... filters)
{
	for (Predicate<L2ItemInstance> additionalFilter : filters)
	{
		filter = filter.and(additionalFilter);
	}
	return _items.values().stream().filter(filter).collect(Collectors.toCollection(LinkedList::new));
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:16,代码来源:ItemContainer.java

示例11: getPaperdollItems

import java.util.function.Predicate; //导入方法依赖的package包/类
/**
 * Gets the items in paperdoll slots filtered by filter.
 * @param filters multiple filters
 * @return the filtered items in inventory
 */
@SafeVarargs
public final Collection<L2ItemInstance> getPaperdollItems(Predicate<L2ItemInstance>... filters)
{
	Predicate<L2ItemInstance> filter = Objects::nonNull;
	for (Predicate<L2ItemInstance> additionalFilter : filters)
	{
		filter = filter.and(additionalFilter);
	}
	return Arrays.stream(_paperdoll).filter(filter).collect(Collectors.toCollection(LinkedList::new));
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:16,代码来源:Inventory.java

示例12: getAutosaveFiles

import java.util.function.Predicate; //导入方法依赖的package包/类
/**
 * Get the autosave files.
 *
 * @param prefix The autosave file prefix.
 * @param pred A {@code Predicate} to select files with.
 * @return A list of of autosaved {@code File}s.
 */
private static List<File> getAutosaveFiles(String prefix,
                                           Predicate<File> pred) {
    final String suffix = "." + FreeCol.FREECOL_SAVE_EXTENSION;
    final File asd = getAutosaveDirectory();
    final Predicate<File> fullPred = pred.and(f ->
        f.getName().startsWith(prefix) && f.getName().endsWith(suffix));
    return (asd == null) ? Collections.emptyList()
        : collectFiles(asd, fullPred);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:17,代码来源:FreeColDirectories.java

示例13: search

import java.util.function.Predicate; //导入方法依赖的package包/类
private void search() {
    boolean searchConcepts = conceptCheckBox.isSelected();
    boolean searchDetails = associationCheckBox.isSelected();
    String concept = conceptCombobox.getSelectionModel().getSelectedItem();
    Association association = associationCombobox.getSelectionModel().getSelectedItem();
    List<Annotation> annotations = new ArrayList<>(toolBox.getData().getAnnotations());
    Predicate<Annotation> nullPredicate = a -> false;
    Predicate<Annotation> conceptPredicate = a -> a.getConcept().equals(concept);
    Predicate<Annotation> associationPredicate = a -> a.getAssociations()
            .stream()
            .anyMatch(ass -> ass.getLinkName().equals(association.getLinkName()) &&
                    ass.getToConcept().equals(association.getToConcept()) &&
                    ass.getLinkValue().equals(association.getLinkValue()));

    Predicate<Annotation> predicate = nullPredicate;

    if (searchConcepts && searchDetails) {
        predicate = conceptPredicate.and(associationPredicate);
    }
    else if (searchConcepts) {
        predicate = conceptPredicate;
    }
    else if (searchDetails) {
        predicate = associationPredicate;
    }

    List<Annotation> foundAnnotations = annotations.stream()
            .filter(predicate)
            .collect(Collectors.toList());

    toolBox.getEventBus()
            .send(new AnnotationsSelectedEvent(foundAnnotations));
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:34,代码来源:BulkEditorPaneController.java

示例14: get

import java.util.function.Predicate; //导入方法依赖的package包/类
@GET
@Path("{itemID : .+}")
@Produces({MediaType.TEXT_PLAIN, "text/csv", MediaType.APPLICATION_JSON})
public List<IDValue> get(
    @PathParam("itemID") List<PathSegment> pathSegments,
    @DefaultValue("10") @QueryParam("howMany") int howMany,
    @DefaultValue("0") @QueryParam("offset") int offset,
    @QueryParam("rescorerParams") List<String> rescorerParams) throws OryxServingException {

  check(!pathSegments.isEmpty(), "Need at least 1 item to make recommendations");
  int howManyOffset = checkHowManyOffset(howMany, offset);

  ALSServingModel model = getALSServingModel();
  List<Pair<String,Double>> parsedPathSegments = EstimateForAnonymous.parsePathSegments(pathSegments);
  float[] anonymousUserFeatures = EstimateForAnonymous.buildTemporaryUserVector(model, parsedPathSegments, null);
  check(anonymousUserFeatures != null, pathSegments.toString());

  List<String> knownItems = parsedPathSegments.stream().map(Pair::getFirst).collect(Collectors.toList());

  Collection<String> knownItemsSet = new HashSet<>(knownItems);
  Predicate<String> allowedFn = v -> !knownItemsSet.contains(v);
  ObjDoubleToDoubleFunction<String> rescoreFn = null;
  RescorerProvider rescorerProvider = getALSServingModel().getRescorerProvider();
  if (rescorerProvider != null) {
    Rescorer rescorer = rescorerProvider.getRecommendToAnonymousRescorer(knownItems,
                                                                         rescorerParams);
    if (rescorer != null) {
      allowedFn = allowedFn.and(id -> !rescorer.isFiltered(id));
      rescoreFn = rescorer::rescore;
    }
  }

  Stream<Pair<String,Double>> topIDDots = model.topN(
      new DotsFunction(anonymousUserFeatures),
      rescoreFn,
      howManyOffset,
      allowedFn);
  return toIDValueResponse(topIDDots, howMany, offset);
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:40,代码来源:RecommendToAnonymous.java

示例15: filterForExport

import java.util.function.Predicate; //导入方法依赖的package包/类
public static Person filterForExport(Person original, int yearsToKeep, long endTime) {
  // filter the patient's history to only the last __ years
  // but also include relevant history from before that. Exclude
  // any history that occurs after the specified end_time -- typically
  // this is the current time/System.currentTimeMillis().

  long cutoffDate = endTime - Utilities.convertTime("years", yearsToKeep);

  Predicate<HealthRecord.Entry> notFutureDated = e -> e.start <= endTime;
  
  // TODO: clone the patient so that we export only the last _ years 
  // but the rest still exists, just in case
  Person filtered = original; //.clone();
  //filtered.record = original.record.clone();

  final HealthRecord record = filtered.record;
  
  for (Encounter encounter : record.encounters) { 
    // keep conditions if still active, regardless of start date
    Predicate<HealthRecord.Entry> conditionActive = c -> record.conditionActive(c.type);
    // or if the condition was active at any point since the cutoff date
    Predicate<HealthRecord.Entry> activeWithinCutoff = c -> c.stop != 0L && c.stop > cutoffDate;
    Predicate<HealthRecord.Entry> keepCondition = conditionActive.or(activeWithinCutoff); 
    filterEntries(encounter.conditions, cutoffDate, endTime, keepCondition);

    // allergies are essentially the same as conditions
    filterEntries(encounter.allergies, cutoffDate, endTime, keepCondition);

    // some of the "future death" logic could potentially add a future-dated death certificate
    Predicate<Observation> isCauseOfDeath =
        o -> DeathModule.CAUSE_OF_DEATH_CODE.code.equals(o.type);
    // keep cause of death unless it's future dated
    Predicate<Observation> keepObservation = isCauseOfDeath.and(notFutureDated);
    filterEntries(encounter.observations, cutoffDate, endTime, keepObservation);

    // keep all death certificates, unless they are future-dated
    Predicate<Report> isDeathCertificate = r -> DeathModule.DEATH_CERTIFICATE.code.equals(r.type);
    Predicate<Report> keepReport = isDeathCertificate.and(notFutureDated);
    filterEntries(encounter.reports, cutoffDate, endTime, keepReport);

    filterEntries(encounter.procedures, cutoffDate, endTime, null);

    // keep medications if still active, regardless of start date
    filterEntries(encounter.medications, cutoffDate, endTime, 
        med -> record.medicationActive(med.type));

    filterEntries(encounter.immunizations, cutoffDate, endTime, null);

    // keep careplans if they are still active, regardless of start date
    filterEntries(encounter.careplans, cutoffDate, endTime, cp -> record.careplanActive(cp.type));
  }

  Predicate<Encounter> encounterNotEmpty = e ->
      !e.conditions.isEmpty() && !e.allergies.isEmpty()
      && !e.observations.isEmpty() && !e.reports.isEmpty()
      && !e.procedures.isEmpty() && !e.medications.isEmpty()
      && !e.immunizations.isEmpty() && !e.careplans.isEmpty();

  Predicate<Encounter> isDeathCertification = 
      e -> !e.codes.isEmpty() && DeathModule.DEATH_CERTIFICATION.equals(e.codes.get(0));
  Predicate<Encounter> keepEncounter = 
      encounterNotEmpty.or(isDeathCertification.and(notFutureDated));

  // finally filter out any empty encounters
  filterEntries(record.encounters, cutoffDate, endTime, keepEncounter);

  return filtered;
}
 
开发者ID:synthetichealth,项目名称:synthea_java,代码行数:69,代码来源:Exporter.java


注:本文中的java.util.function.Predicate.and方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。