@Test public void chainedComparator() { Comparator<Integer> comp = ComparatorUtils.chainedComparator(ComparatorUtils.<Integer>naturalComparator(), ComparatorUtils.<Integer>naturalComparator()); assertTrue(comp.compare(1, 2) < 0); assertTrue(comp.compare(1, 1) == 0); assertTrue(comp.compare(2, 1) > 0); }
public static <E> Comparator<E> chainedComparator(final Comparator<E>... comparators) { final ComparatorChain<E> chain = new ComparatorChain<E>(); for (final Comparator<E> comparator : comparators) { if (comparator == null) { throw new NullPointerException("Comparator cannot be null"); } chain.addComparator(comparator); } return chain; }
ComparatorUtils { public static <E> Comparator<E> chainedComparator(final Comparator<E>... comparators) { final ComparatorChain<E> chain = new ComparatorChain<E>(); for (final Comparator<E> comparator : comparators) { if (comparator == null) { throw new NullPointerException("Comparator cannot be null"); } chain.addComparator(comparator); } return chain; } }
ComparatorUtils { public static <E> Comparator<E> chainedComparator(final Comparator<E>... comparators) { final ComparatorChain<E> chain = new ComparatorChain<E>(); for (final Comparator<E> comparator : comparators) { if (comparator == null) { throw new NullPointerException("Comparator cannot be null"); } chain.addComparator(comparator); } return chain; } private  ComparatorUtils(); }
ComparatorUtils { public static <E> Comparator<E> chainedComparator(final Comparator<E>... comparators) { final ComparatorChain<E> chain = new ComparatorChain<E>(); for (final Comparator<E> comparator : comparators) { if (comparator == null) { throw new NullPointerException("Comparator cannot be null"); } chain.addComparator(comparator); } return chain; } private  ComparatorUtils(); @SuppressWarnings("unchecked") static Comparator<E> naturalComparator(); static Comparator<E> chainedComparator(final Comparator<E>... comparators); @SuppressWarnings("unchecked") static Comparator<E> chainedComparator(final Collection<Comparator<E>> comparators); static Comparator<E> reversedComparator(final Comparator<E> comparator); static Comparator<Boolean> booleanComparator(final boolean trueFirst); @SuppressWarnings("unchecked") static Comparator<E> nullLowComparator(Comparator<E> comparator); @SuppressWarnings("unchecked") static Comparator<E> nullHighComparator(Comparator<E> comparator); @SuppressWarnings("unchecked") static Comparator<I> transformedComparator(Comparator<O> comparator,
            final Transformer<? super I, ? extends O> transformer); @SuppressWarnings("unchecked") static E min(final E o1, final E o2, Comparator<E> comparator); @SuppressWarnings("unchecked") static E max(final E o1, final E o2, Comparator<E> comparator); }
ComparatorUtils { public static <E> Comparator<E> chainedComparator(final Comparator<E>... comparators) { final ComparatorChain<E> chain = new ComparatorChain<E>(); for (final Comparator<E> comparator : comparators) { if (comparator == null) { throw new NullPointerException("Comparator cannot be null"); } chain.addComparator(comparator); } return chain; } private  ComparatorUtils(); @SuppressWarnings("unchecked") static Comparator<E> naturalComparator(); static Comparator<E> chainedComparator(final Comparator<E>... comparators); @SuppressWarnings("unchecked") static Comparator<E> chainedComparator(final Collection<Comparator<E>> comparators); static Comparator<E> reversedComparator(final Comparator<E> comparator); static Comparator<Boolean> booleanComparator(final boolean trueFirst); @SuppressWarnings("unchecked") static Comparator<E> nullLowComparator(Comparator<E> comparator); @SuppressWarnings("unchecked") static Comparator<E> nullHighComparator(Comparator<E> comparator); @SuppressWarnings("unchecked") static Comparator<I> transformedComparator(Comparator<O> comparator,
            final Transformer<? super I, ? extends O> transformer); @SuppressWarnings("unchecked") static E min(final E o1, final E o2, Comparator<E> comparator); @SuppressWarnings("unchecked") static E max(final E o1, final E o2, Comparator<E> comparator); @SuppressWarnings({ "rawtypes", "unchecked" }) // explicit type needed for Java 1.5 compilation
    static final Comparator NATURAL_COMPARATOR; }