@Test public void process() { String file = path + "/text/EnglishWrite.txt"; List<String> lines = FileUtil.lines(new File(file)); Set<String> result = new HashSet<String>(); CollectionHelper.process(lines, result, new ObjectProcess<String, String>() { @Override public String process(String s) { if (s != null && s.length() > 15) { return s; } return null; } }); System.out.println("===="); CollectionHelper.handler(result, new ObjectHandler<String>() { @Override public void handler(String s) { System.out.println(s); } }); }
public static <T, E> void process(Collection<T> collection, Collection<E> result, ObjectProcess<T, E> process) { if (collection == null || collection.size() == 0) { logger.error("collection is empty or is null"); return; } if (result == null || result.size() == 0) { logger.error("receive collection is empty or is null"); return; } for (T t : collection) { E next = process.process(t); if (next != null) { result.add(next); } } }
CollectionHelper { public static <T, E> void process(Collection<T> collection, Collection<E> result, ObjectProcess<T, E> process) { if (collection == null || collection.size() == 0) { logger.error("collection is empty or is null"); return; } if (result == null || result.size() == 0) { logger.error("receive collection is empty or is null"); return; } for (T t : collection) { E next = process.process(t); if (next != null) { result.add(next); } } } }
CollectionHelper { public static <T, E> void process(Collection<T> collection, Collection<E> result, ObjectProcess<T, E> process) { if (collection == null || collection.size() == 0) { logger.error("collection is empty or is null"); return; } if (result == null || result.size() == 0) { logger.error("receive collection is empty or is null"); return; } for (T t : collection) { E next = process.process(t); if (next != null) { result.add(next); } } }  }
CollectionHelper { public static <T, E> void process(Collection<T> collection, Collection<E> result, ObjectProcess<T, E> process) { if (collection == null || collection.size() == 0) { logger.error("collection is empty or is null"); return; } if (result == null || result.size() == 0) { logger.error("receive collection is empty or is null"); return; } for (T t : collection) { E next = process.process(t); if (next != null) { result.add(next); } } }  static void handler(Collection<T> collection, ObjectHandler<T> handler); static void process(Collection<T> collection, Collection<E> result, ObjectProcess<T, E> process); static List<T> removeDuplicate(List<T> list); static List<T> intersection(List<T> list1, List<T> list2); static Set<T> intersection(Set<T> set1, Set<T> set2); static Queue<T> intersection(Queue<T> queue1, Queue<T> queue2); static Map<K, V> intersection(Map<K, V> map1, Map<K, V> map2); static List<T> unicon(List<T> list1, List<T> list2); static Set<T> unicon(Set<T> set1, Set<T> set2); static Queue<T> unicon(Queue<T> queue1, Queue<T> queue2); static Map<K, V> unicon(Map<K, V> map1, Map<K, V> map2); static List<T> subtract(List<T> list1, List<T> list2); static Set<T> subtract(Set<T> set1, Set<T> set2); static Queue<T> subtract(Queue<T> queue1, Queue<T> queue2); static Map<K, V> subtract(Map<K, V> map1, Map<K, V> map2); static String join(Collection<T> collection, String separator); static String join(Map<K, V> map, String separator, String separator1); static String keyJoin(Map<K, V> map, String separator); static String valueJoin(Map<K, V> map, String separator); }
CollectionHelper { public static <T, E> void process(Collection<T> collection, Collection<E> result, ObjectProcess<T, E> process) { if (collection == null || collection.size() == 0) { logger.error("collection is empty or is null"); return; } if (result == null || result.size() == 0) { logger.error("receive collection is empty or is null"); return; } for (T t : collection) { E next = process.process(t); if (next != null) { result.add(next); } } }  static void handler(Collection<T> collection, ObjectHandler<T> handler); static void process(Collection<T> collection, Collection<E> result, ObjectProcess<T, E> process); static List<T> removeDuplicate(List<T> list); static List<T> intersection(List<T> list1, List<T> list2); static Set<T> intersection(Set<T> set1, Set<T> set2); static Queue<T> intersection(Queue<T> queue1, Queue<T> queue2); static Map<K, V> intersection(Map<K, V> map1, Map<K, V> map2); static List<T> unicon(List<T> list1, List<T> list2); static Set<T> unicon(Set<T> set1, Set<T> set2); static Queue<T> unicon(Queue<T> queue1, Queue<T> queue2); static Map<K, V> unicon(Map<K, V> map1, Map<K, V> map2); static List<T> subtract(List<T> list1, List<T> list2); static Set<T> subtract(Set<T> set1, Set<T> set2); static Queue<T> subtract(Queue<T> queue1, Queue<T> queue2); static Map<K, V> subtract(Map<K, V> map1, Map<K, V> map2); static String join(Collection<T> collection, String separator); static String join(Map<K, V> map, String separator, String separator1); static String keyJoin(Map<K, V> map, String separator); static String valueJoin(Map<K, V> map, String separator);  }