@Test public void maxNullSafeShouldReturnNullIfACollectionContainingOnlyNullsIsPassed() { assertThat(maxNullSafe(Arrays.<Integer>asList(null, null, null))).isNull(); }
public static <T> T maxNullSafe(Collection<? extends T> coll, Comparator<? super T> comp) { if (coll == null || coll.isEmpty()) return null; Collection<? extends T> nullFiltered = filter(coll, notNull()); if (nullFiltered.isEmpty()) return null; else return Collections.max(nullFiltered, comp); }
Collections3 { public static <T> T maxNullSafe(Collection<? extends T> coll, Comparator<? super T> comp) { if (coll == null || coll.isEmpty()) return null; Collection<? extends T> nullFiltered = filter(coll, notNull()); if (nullFiltered.isEmpty()) return null; else return Collections.max(nullFiltered, comp); } }
Collections3 { public static <T> T maxNullSafe(Collection<? extends T> coll, Comparator<? super T> comp) { if (coll == null || coll.isEmpty()) return null; Collection<? extends T> nullFiltered = filter(coll, notNull()); if (nullFiltered.isEmpty()) return null; else return Collections.max(nullFiltered, comp); } private  Collections3(); }
Collections3 { public static <T> T maxNullSafe(Collection<? extends T> coll, Comparator<? super T> comp) { if (coll == null || coll.isEmpty()) return null; Collection<? extends T> nullFiltered = filter(coll, notNull()); if (nullFiltered.isEmpty()) return null; else return Collections.max(nullFiltered, comp); } private  Collections3(); static Pair<Collection<E>, Collection<E>> partition(Collection<E> unpartitioned,
                                                                   Predicate<? super E> predicate); static Optional<T> findFirstInstanceOf(Collection<? super T> coll, Class<T> cls); static T maxNullSafe(Collection<? extends T> coll, Comparator<? super T> comp); static T maxNullSafe(Collection<? extends T> coll); }
Collections3 { public static <T> T maxNullSafe(Collection<? extends T> coll, Comparator<? super T> comp) { if (coll == null || coll.isEmpty()) return null; Collection<? extends T> nullFiltered = filter(coll, notNull()); if (nullFiltered.isEmpty()) return null; else return Collections.max(nullFiltered, comp); } private  Collections3(); static Pair<Collection<E>, Collection<E>> partition(Collection<E> unpartitioned,
                                                                   Predicate<? super E> predicate); static Optional<T> findFirstInstanceOf(Collection<? super T> coll, Class<T> cls); static T maxNullSafe(Collection<? extends T> coll, Comparator<? super T> comp); static T maxNullSafe(Collection<? extends T> coll);  }