@Test public void testExists() { final APredicateNoThrow<String> len1 = new APredicateNoThrow<String>() { @Override public boolean apply(String o) { return o.length() == 1; } }; assertEquals(false, ACollectionHelper.exists (Arrays.<String>asList (), len1)); assertEquals(true, ACollectionHelper.exists (Arrays.asList ("a"), len1)); assertEquals(false, ACollectionHelper.exists (Arrays.asList ("ab"), len1)); assertEquals(true, ACollectionHelper.exists (Arrays.asList ("ab", "c", "def"), len1)); }
public static <T, E extends Throwable> boolean exists(Iterable<T> coll, APredicate<? super T, E> pred) throws E { for(T o: coll) { if(pred.apply(o)) { return true; } } return false; }
ACollectionHelper { public static <T, E extends Throwable> boolean exists(Iterable<T> coll, APredicate<? super T, E> pred) throws E { for(T o: coll) { if(pred.apply(o)) { return true; } } return false; } }
ACollectionHelper { public static <T, E extends Throwable> boolean exists(Iterable<T> coll, APredicate<? super T, E> pred) throws E { for(T o: coll) { if(pred.apply(o)) { return true; } } return false; }  }
ACollectionHelper { public static <T, E extends Throwable> boolean exists(Iterable<T> coll, APredicate<? super T, E> pred) throws E { for(T o: coll) { if(pred.apply(o)) { return true; } } return false; }  static Set<T> createSet(Iterator<T> elements); static Set<T> createSet(Iterable<T> elements); static Set<U> createSet(Iterator<T> elements, AFunction1<T,U,E> f); static Set<U> createSet(Iterable<T> elements, AFunction1<T,U,E> f); static String mkString(Iterable<?> iterable); static String mkString(Iterable<?> iterable, String separator); static String mkString(Iterable<?> iterable, String prefix, String separator, String suffix); static AOption<T> find(Iterable<T> coll, APredicate<? super T, E> pred); static boolean forAll(Iterable<T> coll, APredicate<? super T, E> pred); static boolean exists(Iterable<T> coll, APredicate<? super T, E> pred); static Collection<X> map(Iterable<T> coll, AFunction1<? super T, ? extends X, E> f); static List<X> map(List<T> coll, AFunction1<? super T, ? extends X, E> f); static Set<X> map(Set<T> coll, AFunction1<? super T, ? extends X, E> f); static Collection<X> flatMap(Iterable<T> coll, AFunction1<? super T, ? extends Iterable<X>, E> f); static List<X> flatMapList(Iterable<T> coll, AFunction1<? super T, ? extends Iterable<X>, E> f); static Set<X> flatMapSet(Iterable<T> coll, AFunction1<? super T, ? extends Iterable<X>, E> f); static Collection<T> flatten(Iterable<? extends Iterable<T>> coll); static List<T> flattenList(Iterable<? extends Iterable<T>> coll); static Set<T> flattenSet(Iterable<? extends Iterable<T>> coll); static Collection<X> collect(Iterable<T> coll, APartialFunction<? super T, ? extends X, E> pf); static List<X> collect(List<T> coll, APartialFunction<? super T, ? extends X, E> pf); static Set<X> collect(Set<T> coll, APartialFunction<? super T, ? extends X, E> pf); static Collection<T> filter(Iterable<T> coll, APredicate<? super T, E> pred); static List<T> filter(List<T> coll, APredicate<? super T, E> pred); static Set<T> filter(Set<T> coll, APredicate<? super T, E> pred); static Collection<T> filterNot(Iterable<T> coll, APredicate<? super T, E> pred); static List<T> filterNot(List<T> coll, APredicate<? super T, E> pred); static Set<T> filterNot(Set<T> coll, APredicate<? super T, E> pred); static Map<X, Collection<T>> groupBy(Iterable<T> coll, AFunction1<? super T, ? extends X, E> f); static Map<X, List<T>> groupBy(List<T> coll, AFunction1<? super T, ? extends X, E> f); static Map<X, Set<T>> groupBy(Set<T> coll, AFunction1<? super T, ? extends X, E> f); static Map<AEqualsWrapper<X>, Collection<T>> groupBy(Iterable<T> coll, AFunction1<? super T, ? extends X, E> f, AEquality keyEquality); static Map<AEqualsWrapper<X>, List<T>> groupBy(List<T> coll, AFunction1<? super T, ? extends X, E> f, AEquality keyEquality); static Map<AEqualsWrapper<X>, Set<T>> groupBy(Set<T> coll, AFunction1<? super T, ? extends X, E> f, AEquality keyEquality); static R foldLeft(Iterable<T> coll, R startValue, AFunction2<R, ? super T, R, E> f); static R foldRight(List<T> coll, R startValue, AFunction2<R, ? super T, R, E> f); static ACollectionWrapper<T> asACollectionCopy(Collection<T> c); @SuppressWarnings("unchecked") static ACollectionWrapper<T> asACollectionView(Collection<T> c); static ASetWrapper<T> asASetView(Collection<T> c); @SuppressWarnings("unchecked") static AArrayWrapper<T> asArrayCopy(T[] c); static AArrayWrapper<T> asArrayView(T[] c); static List<T> asJavaUtilList(Iterable<T> c); static Collection<T> asJavaUtilCollection(Iterable<T> c); static List<T> asJavaUtilCollection(Iterator<T> c); }
ACollectionHelper { public static <T, E extends Throwable> boolean exists(Iterable<T> coll, APredicate<? super T, E> pred) throws E { for(T o: coll) { if(pred.apply(o)) { return true; } } return false; }  static Set<T> createSet(Iterator<T> elements); static Set<T> createSet(Iterable<T> elements); static Set<U> createSet(Iterator<T> elements, AFunction1<T,U,E> f); static Set<U> createSet(Iterable<T> elements, AFunction1<T,U,E> f); static String mkString(Iterable<?> iterable); static String mkString(Iterable<?> iterable, String separator); static String mkString(Iterable<?> iterable, String prefix, String separator, String suffix); static AOption<T> find(Iterable<T> coll, APredicate<? super T, E> pred); static boolean forAll(Iterable<T> coll, APredicate<? super T, E> pred); static boolean exists(Iterable<T> coll, APredicate<? super T, E> pred); static Collection<X> map(Iterable<T> coll, AFunction1<? super T, ? extends X, E> f); static List<X> map(List<T> coll, AFunction1<? super T, ? extends X, E> f); static Set<X> map(Set<T> coll, AFunction1<? super T, ? extends X, E> f); static Collection<X> flatMap(Iterable<T> coll, AFunction1<? super T, ? extends Iterable<X>, E> f); static List<X> flatMapList(Iterable<T> coll, AFunction1<? super T, ? extends Iterable<X>, E> f); static Set<X> flatMapSet(Iterable<T> coll, AFunction1<? super T, ? extends Iterable<X>, E> f); static Collection<T> flatten(Iterable<? extends Iterable<T>> coll); static List<T> flattenList(Iterable<? extends Iterable<T>> coll); static Set<T> flattenSet(Iterable<? extends Iterable<T>> coll); static Collection<X> collect(Iterable<T> coll, APartialFunction<? super T, ? extends X, E> pf); static List<X> collect(List<T> coll, APartialFunction<? super T, ? extends X, E> pf); static Set<X> collect(Set<T> coll, APartialFunction<? super T, ? extends X, E> pf); static Collection<T> filter(Iterable<T> coll, APredicate<? super T, E> pred); static List<T> filter(List<T> coll, APredicate<? super T, E> pred); static Set<T> filter(Set<T> coll, APredicate<? super T, E> pred); static Collection<T> filterNot(Iterable<T> coll, APredicate<? super T, E> pred); static List<T> filterNot(List<T> coll, APredicate<? super T, E> pred); static Set<T> filterNot(Set<T> coll, APredicate<? super T, E> pred); static Map<X, Collection<T>> groupBy(Iterable<T> coll, AFunction1<? super T, ? extends X, E> f); static Map<X, List<T>> groupBy(List<T> coll, AFunction1<? super T, ? extends X, E> f); static Map<X, Set<T>> groupBy(Set<T> coll, AFunction1<? super T, ? extends X, E> f); static Map<AEqualsWrapper<X>, Collection<T>> groupBy(Iterable<T> coll, AFunction1<? super T, ? extends X, E> f, AEquality keyEquality); static Map<AEqualsWrapper<X>, List<T>> groupBy(List<T> coll, AFunction1<? super T, ? extends X, E> f, AEquality keyEquality); static Map<AEqualsWrapper<X>, Set<T>> groupBy(Set<T> coll, AFunction1<? super T, ? extends X, E> f, AEquality keyEquality); static R foldLeft(Iterable<T> coll, R startValue, AFunction2<R, ? super T, R, E> f); static R foldRight(List<T> coll, R startValue, AFunction2<R, ? super T, R, E> f); static ACollectionWrapper<T> asACollectionCopy(Collection<T> c); @SuppressWarnings("unchecked") static ACollectionWrapper<T> asACollectionView(Collection<T> c); static ASetWrapper<T> asASetView(Collection<T> c); @SuppressWarnings("unchecked") static AArrayWrapper<T> asArrayCopy(T[] c); static AArrayWrapper<T> asArrayView(T[] c); static List<T> asJavaUtilList(Iterable<T> c); static Collection<T> asJavaUtilCollection(Iterable<T> c); static List<T> asJavaUtilCollection(Iterator<T> c);  }