com.atlassian.jira.issue.comparator
Class NullComparator

java.lang.Object
  extended by com.atlassian.jira.issue.comparator.NullComparator
All Implemented Interfaces:
java.util.Comparator

public class NullComparator
extends java.lang.Object
implements java.util.Comparator

This comparator compares two given objects and is null safe.


Constructor Summary
NullComparator()
           
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares two given objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

NullComparator

public NullComparator()
Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
            throws java.lang.ClassCastException
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 of Comparable and o2 is not of the same type may result in ClassCastException.

Specified by:
compare in interface java.util.Comparator
Parameters:
o1 - object to compare
o2 - object to compare
Returns:
result of comparison
Throws:
java.lang.ClassCastException - if o1 is an instance of Comparable and o2 is not of the same type


Copyright © 2002-2010 Atlassian. All Rights Reserved.