public final class MiscUtils extends Object
Modifier and Type | Method and Description |
---|---|
static <T extends Comparable<? super T>> |
compare(T o1,
T o2)
Compares two comparable objects, even if one or both of them are null.
|
static <T extends Comparable<? super T>> |
compare(T o1,
T o2,
boolean heavyNulls)
Compares two comparable objects, even if one or both of them are null.
|
static boolean |
equal(Object o1,
Object o2)
Deprecated.
Use
Objects.equals(Object, Object) instead. |
public static <T extends Comparable<? super T>> int compare(T o1, T o2)
By convention, nulls are considered less than non-nulls (and will hence will appear first on sorted lists).
o1
- The first object to compare.o2
- The second object to compare.o1.compareTo(o2)
unless one or both of them
is null, in which case nulls are considered less than non-null
objects.public static <T extends Comparable<? super T>> int compare(T o1, T o2, boolean heavyNulls)
o1
- The first object to compare.o2
- The second object to compare.heavyNulls
- If true, nulls will be treated as greater than non-nulls,
and hence "sink to the bottom" of e.g. sorted lists.o1.compareTo(o2)
unless one or both of them
is null, in which case the null strategy defined by the
heavyNulls
flag is used, to define nulls as either less
than, or greater than, non-null objects.@Deprecated public static boolean equal(Object o1, Object o2)
Objects.equals(Object, Object)
instead.Copyright © 2015–2022 SciJava. All rights reserved.