PatentClassification implements Classification { public static <T extends PatentClassification> SortedSet<T> filterByType(Collection<PatentClassification> classes, ClassificationType wantedType) { return filterByType(classes, wantedType.getJavaClass()); } PatentClassification(String originalText, boolean mainOrInventive); @Override String getTextOriginal(); boolean isMainOrInventive(); @Override String toText(); @Override int compareTo(Classification other); static List<T> fromText(Iterable<String> classificationStrings,
			Class<T> classificationClass); static boolean match(Collection<T> classes,
			Predicate<PatentClassification> predicate); static SortedSet<T> filter(Collection<T> classes,
			Predicate<PatentClassification> predicate); static Map<ClassificationType, Set<PatentClassification>> groupByType(
			Collection<PatentClassification> classes); static SortedSet<T> filterByType(Collection<PatentClassification> classes,
			ClassificationType wantedType); static SortedSet<T> filterByType(Collection<PatentClassification> classes,
			Class<T> wantedClass); static Set<String> getFacetByType(Collection<PatentClassification> classes, ClassificationType wantedType); static Set<String> getFacet(Collection<T> classes);  }
@Test public void filerByType_ClassificationType() throws ParseException { List<PatentClassification> claz = new ArrayList<PatentClassification>(); CpcClassification cpcClass = new CpcClassification("D21", false); cpcClass.parseText("D21"); claz.add(cpcClass); IpcClassification ipcClass = new IpcClassification("D22", false); ipcClass.parseText("D22"); claz.add(ipcClass); UspcClassification uspc = new UspcClassification("PLT101", false); uspc.parseText("PLT101"); claz.add(uspc); Set<PatentClassification> ret = PatentClassification.filterByType(claz, ClassificationType.CPC); assertTrue(ret.size() == 1); assertEquals(cpcClass, ret.iterator().next()); Set<PatentClassification> ret2 = PatentClassification.filterByType(claz, ClassificationType.IPC); assertTrue(ret2.size() == 1); assertEquals(ipcClass, ret2.iterator().next()); Set<PatentClassification> ret3 = PatentClassification.filterByType(claz, ClassificationType.USPC); assertTrue(ret3.size() == 1); assertEquals(uspc, ret3.iterator().next()); }
@Test public void filerByType_Class() throws ParseException { List<PatentClassification> claz = new ArrayList<PatentClassification>(); CpcClassification cpcClass = new CpcClassification("D21", false); cpcClass.parseText("D21"); claz.add(cpcClass); IpcClassification ipcClass = new IpcClassification("D22", false); ipcClass.parseText("D22"); claz.add(ipcClass); UspcClassification uspc = new UspcClassification("PLT101", false); uspc.parseText("PLT101"); claz.add(uspc); Set<CpcClassification> ret = PatentClassification.filterByType(claz, CpcClassification.class); assertTrue(ret.size() == 1); assertEquals(cpcClass, ret.iterator().next()); Set<IpcClassification> ret2 = PatentClassification.filterByType(claz, IpcClassification.class); assertTrue(ret2.size() == 1); assertEquals(ipcClass, ret2.iterator().next()); Set<UspcClassification> ret3 = PatentClassification.filterByType(claz, UspcClassification.class); assertTrue(ret3.size() == 1); assertEquals(uspc, ret3.iterator().next()); }