@Test public void testWhenSecondParamIsNull() { assertEquals(1, safeComparator.compare(param1, null)); verify(comparator, never()).compare(any(), any()); }
@Override public int compare(final T obj1, final T obj2) { if (obj1 == null) { return obj2 != null ? -1 : 0; } else if (obj2 == null) { return 1; } else { return comparatorSupplier.get().compare(obj1, obj2); } }
SafeComparator implements Comparator<T> { @Override public int compare(final T obj1, final T obj2) { if (obj1 == null) { return obj2 != null ? -1 : 0; } else if (obj2 == null) { return 1; } else { return comparatorSupplier.get().compare(obj1, obj2); } } }
SafeComparator implements Comparator<T> { @Override public int compare(final T obj1, final T obj2) { if (obj1 == null) { return obj2 != null ? -1 : 0; } else if (obj2 == null) { return 1; } else { return comparatorSupplier.get().compare(obj1, obj2); } } private  SafeComparator(Supplier<Comparator<T>> comparatorSupplier); }
SafeComparator implements Comparator<T> { @Override public int compare(final T obj1, final T obj2) { if (obj1 == null) { return obj2 != null ? -1 : 0; } else if (obj2 == null) { return 1; } else { return comparatorSupplier.get().compare(obj1, obj2); } } private  SafeComparator(Supplier<Comparator<T>> comparatorSupplier); static SafeComparator<K> of(Supplier<Comparator<K>> comparatorSupplier); @Override int compare(final T obj1,
                       final T obj2); }
SafeComparator implements Comparator<T> { @Override public int compare(final T obj1, final T obj2) { if (obj1 == null) { return obj2 != null ? -1 : 0; } else if (obj2 == null) { return 1; } else { return comparatorSupplier.get().compare(obj1, obj2); } } private  SafeComparator(Supplier<Comparator<T>> comparatorSupplier); static SafeComparator<K> of(Supplier<Comparator<K>> comparatorSupplier); @Override int compare(final T obj1,
                       final T obj2); static final SafeComparator<Object> TO_STRING_COMPARATOR; static final SafeComparator<Object> TO_STRING_REVERSE_COMPARATOR; }