Class NullComparator
java.lang.Object
com.atlassian.jira.issue.comparator.NullComparator
- All Implemented Interfaces:
Comparator
This comparator compares two given objects and is null safe.
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
NullComparator
public NullComparator()
-
-
Method Details
-
compare
Compares two given objects. Returns 0 if both objects are null, 1 if o2 is null, -1 if o1 is null. In case when both objects are not null, returns the result of o1.compareTo(o2) as long as o1 implements Comparable, otherwise returns 0.
Note that if o1 is an instance ofComparableand o2 is not of the same type may result inClassCastException.- Specified by:
comparein interfaceComparator- Parameters:
o1- object to compareo2- object to compare- Returns:
- result of comparison
- Throws:
ClassCastException- if o1 is an instance ofComparableand o2 is not of the same type
-