ClassificationPredicate { public static <T extends PatentClassification> Predicate<PatentClassification> isContained(T wantedClass) { return p -> p.getType() == wantedClass.getType() && wantedClass.isContained(p); }  static Predicate<PatentClassification> isContained(T wantedClass); static Predicate<PatentClassification> isContained(
			Iterable<T> wantedClasses); static Predicate<PatentClassification> isContained(
			Iterable<String> wantedClassStrs, Class<T> classificationClass); static Predicate<PatentClassification> isType(ClassificationType wantedType);  }
@Test public void contained_false() throws ParseException { CpcClassification wantCpc = new CpcClassification("A01B300", false); wantCpc.parseText("A01B300"); Predicate<PatentClassification> predicate = ClassificationPredicate.isContained(wantCpc); CpcClassification checkCpc = new CpcClassification("A01B33/00", false); checkCpc.parseText("A01B33/00"); assertFalse(wantCpc.isContained(checkCpc)); assertFalse(predicate.test(checkCpc)); }
@Test public void contained_true() throws ParseException { CpcClassification wantCpc = new CpcClassification("D07B", false); wantCpc.parseText("D07B"); Predicate<PatentClassification> predicate = ClassificationPredicate.isContained(wantCpc); CpcClassification checkCpc = new CpcClassification("D07B22012051", false); checkCpc.parseText("D07B22012051"); assertTrue(wantCpc.isContained(checkCpc)); assertTrue(predicate.test(checkCpc)); }
@Test public void testList() throws ParseException { CpcClassification wantCpc = new CpcClassification("D07B", true); wantCpc.parseText("D07B"); Predicate<PatentClassification> predicate = ClassificationPredicate.isContained(wantCpc); CpcClassification cpc1 = new CpcClassification("D07B22012051", true); cpc1.parseText("D07B22012051"); CpcClassification cpc2 = new CpcClassification("A01B300", true); cpc2.parseText("A01B300"); Set<CpcClassification> cpcClasses = new HashSet<CpcClassification>(); cpcClasses.add(cpc1); cpcClasses.add(cpc2); assertTrue(cpcClasses.stream().anyMatch(predicate)); }
@Test public void equal() throws ParseException { CpcClassification wantCpc = new CpcClassification("A01B300", true); wantCpc.parseText("A01B300"); Predicate<PatentClassification> predicate = ClassificationPredicate.isContained(wantCpc); CpcClassification checkCpc = new CpcClassification("A01B300", true); checkCpc.parseText("A01B300"); assertTrue(wantCpc.equals(checkCpc)); }