/** * Return a decorator for the given comparator which accepts * null values and sorts them lower than non-null values. * @see NullSafeComparator#NullSafeComparator(boolean) */ public static <T> Comparator<T> nullsLow(Comparator<T> comparator) { return new NullSafeComparator<>(comparator, true); }
@SuppressWarnings("unchecked") private boolean areEqual(SimilarityType<?> similarityType, SimilarityType<?> type) { if (similarityType instanceof SimilarityTypeEnum) { return NullSafeComparator.NULLS_LOW.compare(type, similarityType) == 0; } else { return NullSafeComparator.NULLS_LOW.compare(similarityType, type) == 0; } }
@SuppressWarnings("unchecked") @Override public int compareTo(T o) { if (o == null) { return -Integer.MAX_VALUE; } return NullSafeComparator.NULLS_LOW.compare(name(), o.name()); }
/** * Return a decorator for the given comparator which accepts * null values and sorts them higher than non-null values. * @see NullSafeComparator#NullSafeComparator(boolean) */ public static <T> Comparator<T> nullsHigh(Comparator<T> comparator) { return new NullSafeComparator<>(comparator, false); }
/** * Return a decorator for the given comparator which accepts * null values and sorts them lower than non-null values. * @see NullSafeComparator#NullSafeComparator(boolean) */ public static <T> Comparator<T> nullsLow(Comparator<T> comparator) { return new NullSafeComparator<>(comparator, true); }
/** * Return a decorator for the given comparator which accepts * null values and sorts them higher than non-null values. * @see NullSafeComparator#NullSafeComparator(boolean) */ public static <T> Comparator<T> nullsHigh(Comparator<T> comparator) { return new NullSafeComparator<>(comparator, false); }
public int compare(Object o1, Object o2) { LabeledEnum e1 = (LabeledEnum) o1; LabeledEnum e2 = (LabeledEnum) o2; Comparator comp = new NullSafeComparator(String.CASE_INSENSITIVE_ORDER, true); return comp.compare(e1.getLabel(), e2.getLabel()); } };
/** * Return a decorator for the given comparator which accepts * null values and sorts them lower than non-null values. * @see NullSafeComparator#NullSafeComparator(boolean) */ public static <T> Comparator<T> nullsLow(Comparator<T> comparator) { return new NullSafeComparator<>(comparator, true); }
/** * Return a decorator for the given comparator which accepts * null values and sorts them higher than non-null values. * @see NullSafeComparator#NullSafeComparator(boolean) */ public static <T> Comparator<T> nullsHigh(Comparator<T> comparator) { return new NullSafeComparator<>(comparator, false); }
/** * Return a decorator for the given comparator which accepts * null values and sorts them lower than non-null values. * @see NullSafeComparator#NullSafeComparator(boolean) */ public static <T> Comparator<T> nullsLow(Comparator<T> comparator) { return new NullSafeComparator<>(comparator, true); }
/** * Return a decorator for the given comparator which accepts * null values and sorts them higher than non-null values. * @see NullSafeComparator#NullSafeComparator(boolean) */ public static <T> Comparator<T> nullsHigh(Comparator<T> comparator) { return new NullSafeComparator<>(comparator, false); }
public int compare(Object o1, Object o2) { LabeledEnum e1 = (LabeledEnum) o1; LabeledEnum e2 = (LabeledEnum) o2; Comparator comp = new NullSafeComparator(String.CASE_INSENSITIVE_ORDER, true); return comp.compare(e1.getLabel(), e2.getLabel()); } };