@Test public void matchany() { Assert.assertTrue(CollectionUtils.match(MatchMode.any, collection(new String[] { "a", "b" }), Op.containsBy, "abc")); Assert.assertTrue(CollectionUtils.match(MatchMode.any, collection(new String[] { "abcd", "abcddafsasd" }), Op.equal, "abcd")); Assert.assertTrue(CollectionUtils.match(MatchMode.any, collection(new String[] { "abcdadfad", "fabcd" }), Op.containIgnoreCase, "ABCD")); Assert.assertFalse(CollectionUtils.match(MatchMode.any, collection(new String[] { "abcd", "fabcd" }), Op.containIgnoreCase, "eABC")); }
public static <T> boolean match(MatchMode mode, Collection<T> array, Op op, T search) { for (T source : array) { switch (mode) { case all: if (op.match(source, search) == false) { return false; } break; case any: if (op.match(source, search) == true) { return true; } break; } } return mode.isAll() ? true : false; }
CollectionUtils { public static <T> boolean match(MatchMode mode, Collection<T> array, Op op, T search) { for (T source : array) { switch (mode) { case all: if (op.match(source, search) == false) { return false; } break; case any: if (op.match(source, search) == true) { return true; } break; } } return mode.isAll() ? true : false; } }
CollectionUtils { public static <T> boolean match(MatchMode mode, Collection<T> array, Op op, T search) { for (T source : array) { switch (mode) { case all: if (op.match(source, search) == false) { return false; } break; case any: if (op.match(source, search) == true) { return true; } break; } } return mode.isAll() ? true : false; }  }
CollectionUtils { public static <T> boolean match(MatchMode mode, Collection<T> array, Op op, T search) { for (T source : array) { switch (mode) { case all: if (op.match(source, search) == false) { return false; } break; case any: if (op.match(source, search) == true) { return true; } break; } } return mode.isAll() ? true : false; }  static List<T> convertSetToList(Set<T> set); static List<T> removeAll(Collection<T> collection, Collection<T> remove); static void addAll(Collection<T> target, Collection<T> source); static List<T> filter(Collection<T> values, Grep<T> grep); static Set<T> filterSet(Collection<T> values, Grep<T> grep); static void remove(Collection<T> values, Grep<T> grep); static void remove(Collection<T> values, Grep<T> grep, int limit); static boolean isAll(Collection<T> array, Op op, Collection<T> search); static boolean isAll(Collection<T> array, Op op, T search); static boolean isAny(Collection<T> array, Op op, T search); static boolean isAny(Collection<T> array, Op op, Collection<T> search); static boolean isAnyArray(T word, Op op, Collection<T> searhArray); static boolean matchs(MatchMode mode, Collection<T> array, Op op, Collection<T> searchArray); static boolean match(MatchMode mode, Collection<T> array, Op op, T search); static Map<Integer, T> toIntegerMap(Collection<T> values, String property); static Map<Long, T> toLongMap(Collection<T> values, String property); static Map<Float, T> toFloatMap(Collection<T> values, String property); static Map<Double, T> toDoubleMap(Collection<T> values, String property); static Map<Object, Object> toMap(T[] beans, String keyProperty, String valueProperty); static Map<String, T> toMap(Collection<T> values, String property); static Map<String, List<T>> toListMap(Collection<T> values, String property); static Map<Long, List<T>> toLongListMap(Collection<T> values, String property); static void merge(M original, M destination, List<String> ignore); static T mergeList(List<T> list, List<String> ignore); static Long[] getLongValueArrays(Collection<?> values, String property); static List<Long> getLongValues(Collection<?> values); static List<Long> getLongValues(Collection<?> values, String property); static List<Float> getFloatValues(Collection<?> values); static Float[] getFloatValueArray(Collection<?> values); static List<Float> getFloatValues(Collection<?> values, String property); static List<Integer> getIntegerValues(Collection<?> values); static Integer[] getIntegerValueArray(Collection<?> values); static Integer[] getIntegerValueArray(Collection<?> values, String property); static List<Integer> getIntegerValues(Collection<?> values, String property); static List<Double> getDoubleValues(Collection<?> values); static Double[] getDoubleValueArray(Collection<?> values); static List<Double> getDoubleValues(Collection<?> values, String property); static List<Number> getNumberProperty(Collection<?> values, String property); static String[] getPropertyArray(Collection<?> values, String property); static List<String> getProperty(Collection<?> values, String property); static boolean isEqualCollection(Collection<Long> currentCids, Collection<Long> newCids); static List<T> join(String property, Collection<T>... arrays); static String[] getArrayProperty(Object[] objects, String property); }
CollectionUtils { public static <T> boolean match(MatchMode mode, Collection<T> array, Op op, T search) { for (T source : array) { switch (mode) { case all: if (op.match(source, search) == false) { return false; } break; case any: if (op.match(source, search) == true) { return true; } break; } } return mode.isAll() ? true : false; }  static List<T> convertSetToList(Set<T> set); static List<T> removeAll(Collection<T> collection, Collection<T> remove); static void addAll(Collection<T> target, Collection<T> source); static List<T> filter(Collection<T> values, Grep<T> grep); static Set<T> filterSet(Collection<T> values, Grep<T> grep); static void remove(Collection<T> values, Grep<T> grep); static void remove(Collection<T> values, Grep<T> grep, int limit); static boolean isAll(Collection<T> array, Op op, Collection<T> search); static boolean isAll(Collection<T> array, Op op, T search); static boolean isAny(Collection<T> array, Op op, T search); static boolean isAny(Collection<T> array, Op op, Collection<T> search); static boolean isAnyArray(T word, Op op, Collection<T> searhArray); static boolean matchs(MatchMode mode, Collection<T> array, Op op, Collection<T> searchArray); static boolean match(MatchMode mode, Collection<T> array, Op op, T search); static Map<Integer, T> toIntegerMap(Collection<T> values, String property); static Map<Long, T> toLongMap(Collection<T> values, String property); static Map<Float, T> toFloatMap(Collection<T> values, String property); static Map<Double, T> toDoubleMap(Collection<T> values, String property); static Map<Object, Object> toMap(T[] beans, String keyProperty, String valueProperty); static Map<String, T> toMap(Collection<T> values, String property); static Map<String, List<T>> toListMap(Collection<T> values, String property); static Map<Long, List<T>> toLongListMap(Collection<T> values, String property); static void merge(M original, M destination, List<String> ignore); static T mergeList(List<T> list, List<String> ignore); static Long[] getLongValueArrays(Collection<?> values, String property); static List<Long> getLongValues(Collection<?> values); static List<Long> getLongValues(Collection<?> values, String property); static List<Float> getFloatValues(Collection<?> values); static Float[] getFloatValueArray(Collection<?> values); static List<Float> getFloatValues(Collection<?> values, String property); static List<Integer> getIntegerValues(Collection<?> values); static Integer[] getIntegerValueArray(Collection<?> values); static Integer[] getIntegerValueArray(Collection<?> values, String property); static List<Integer> getIntegerValues(Collection<?> values, String property); static List<Double> getDoubleValues(Collection<?> values); static Double[] getDoubleValueArray(Collection<?> values); static List<Double> getDoubleValues(Collection<?> values, String property); static List<Number> getNumberProperty(Collection<?> values, String property); static String[] getPropertyArray(Collection<?> values, String property); static List<String> getProperty(Collection<?> values, String property); static boolean isEqualCollection(Collection<Long> currentCids, Collection<Long> newCids); static List<T> join(String property, Collection<T>... arrays); static String[] getArrayProperty(Object[] objects, String property);  }