Package org.scijava.util
Class MiscUtils
- java.lang.Object
-
- org.scijava.util.MiscUtils
-
public final class MiscUtils extends Object
Miscellaneous utility methods. Every project needs a class like this, right?- Author:
- Curtis Rueden
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T extends Comparable<? super T>>
intcompare(T o1, T o2)Compares two comparable objects, even if one or both of them are null.static <T extends Comparable<? super T>>
intcompare(T o1, T o2, boolean heavyNulls)Compares two comparable objects, even if one or both of them are null.static booleanequal(Object o1, Object o2)Deprecated.UseObjects.equals(Object, Object)instead.
-
-
-
Method Detail
-
compare
public static <T extends Comparable<? super T>> int compare(T o1, T o2)
Compares two comparable objects, even if one or both of them are null.By convention, nulls are considered less than non-nulls (and will hence will appear first on sorted lists).
- Parameters:
o1- The first object to compare.o2- The second object to compare.- Returns:
- The result of
o1.compareTo(o2)unless one or both of them is null, in which case nulls are considered less than non-null objects.
-
compare
public static <T extends Comparable<? super T>> int compare(T o1, T o2, boolean heavyNulls)
Compares two comparable objects, even if one or both of them are null.- Parameters:
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.- Returns:
- The result of
o1.compareTo(o2)unless one or both of them is null, in which case the null strategy defined by theheavyNullsflag is used, to define nulls as either less than, or greater than, non-null objects.
-
equal
@Deprecated public static boolean equal(Object o1, Object o2)
Deprecated.UseObjects.equals(Object, Object)instead.
-
-