@Test public void test06() { List<String> regulars = new ArrayList<String>(); String regular1 = "pt=1/ds=s[a-z]*"; String regular2 = "pt=1/ds=*"; regulars.add(regular1); regulars.add(regular2); List<String> matched = FilterUtil.filterByRegulars(ALL_STRS, regulars); System.out.println("matched:" + matched); List<String> expected = new ArrayList<String>(); expected.add(ALL_STRS.get(0)); expected.add(ALL_STRS.get(1)); Assert.assertEquals(expected.size(), matched.size()); Collections.sort(expected); Collections.sort(matched); Assert.assertArrayEquals(expected.toArray(), matched.toArray()); }
public static List<String> filterByRegulars(List<String> allStrs, List<String> regulars) { List<String> matchedValues = new ArrayList<String>(); List<String> tempMatched = null; for (String regular : regulars) { tempMatched = filterByRegular(allStrs, regular); if (null != tempMatched && !tempMatched.isEmpty()) { for (String temp : tempMatched) { if (!matchedValues.contains(temp)) { matchedValues.add(temp); } } } } return matchedValues; }
FilterUtil { public static List<String> filterByRegulars(List<String> allStrs, List<String> regulars) { List<String> matchedValues = new ArrayList<String>(); List<String> tempMatched = null; for (String regular : regulars) { tempMatched = filterByRegular(allStrs, regular); if (null != tempMatched && !tempMatched.isEmpty()) { for (String temp : tempMatched) { if (!matchedValues.contains(temp)) { matchedValues.add(temp); } } } } return matchedValues; } }
FilterUtil { public static List<String> filterByRegulars(List<String> allStrs, List<String> regulars) { List<String> matchedValues = new ArrayList<String>(); List<String> tempMatched = null; for (String regular : regulars) { tempMatched = filterByRegular(allStrs, regular); if (null != tempMatched && !tempMatched.isEmpty()) { for (String temp : tempMatched) { if (!matchedValues.contains(temp)) { matchedValues.add(temp); } } } } return matchedValues; }  }
FilterUtil { public static List<String> filterByRegulars(List<String> allStrs, List<String> regulars) { List<String> matchedValues = new ArrayList<String>(); List<String> tempMatched = null; for (String regular : regulars) { tempMatched = filterByRegular(allStrs, regular); if (null != tempMatched && !tempMatched.isEmpty()) { for (String temp : tempMatched) { if (!matchedValues.contains(temp)) { matchedValues.add(temp); } } } } return matchedValues; }  static List<String> filterByRegular(List<String> allStrs,
                                               String regular); static List<String> filterByRegulars(List<String> allStrs,
                                                List<String> regulars); }
FilterUtil { public static List<String> filterByRegulars(List<String> allStrs, List<String> regulars) { List<String> matchedValues = new ArrayList<String>(); List<String> tempMatched = null; for (String regular : regulars) { tempMatched = filterByRegular(allStrs, regular); if (null != tempMatched && !tempMatched.isEmpty()) { for (String temp : tempMatched) { if (!matchedValues.contains(temp)) { matchedValues.add(temp); } } } } return matchedValues; }  static List<String> filterByRegular(List<String> allStrs,
                                               String regular); static List<String> filterByRegulars(List<String> allStrs,
                                                List<String> regulars);  }