| java.lang.Object org.apache.commons.collections.comparators.NullComparator
NullComparator | public class NullComparator implements Comparator,Serializable(Code) | | A Comparator that will compare nulls to be either lower or higher than
other objects.
since: Commons Collections 2.0 version: $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $ author: Michael A. Smith |
Constructor Summary | |
public | NullComparator() Construct an instance that sorts null higher than any
non-null object it is compared with. | public | NullComparator(Comparator nonNullComparator) Construct an instance that sorts null higher than any
non-null object it is compared with. | public | NullComparator(boolean nullsAreHigh) Construct an instance that sorts null higher or lower than
any non-null object it is compared with. | public | NullComparator(Comparator nonNullComparator, boolean nullsAreHigh) Construct an instance that sorts null higher or lower than
any non-null object it is compared with. |
Method Summary | |
public int | compare(Object o1, Object o2) Perform a comparison between two objects. | public boolean | equals(Object obj) Determines whether the specified object represents a comparator that is
equal to this comparator.
Parameters: obj - the object to compare this comparator with. | public int | hashCode() Implement a hash code for this comparator that is consistent with
NullComparator.equals(Object) . |
NullComparator | public NullComparator()(Code) | | Construct an instance that sorts null higher than any
non-null object it is compared with. When comparing two
non-null objects, the
ComparableComparator is
used.
|
NullComparator | public NullComparator(Comparator nonNullComparator)(Code) | | Construct an instance that sorts null higher than any
non-null object it is compared with. When comparing two
non-null objects, the specified
Comparator is
used.
Parameters: nonNullComparator - the comparator to use when comparing twonon-null objects. This argument cannot benull exception: NullPointerException - if nonNullComparator isnull |
NullComparator | public NullComparator(boolean nullsAreHigh)(Code) | | Construct an instance that sorts null higher or lower than
any non-null object it is compared with. When comparing
two non-null objects, the
ComparableComparator is
used.
Parameters: nullsAreHigh - a true value indicates thatnull should be compared as higher than anon-null object. A false value indicatesthat null should be compared as lower than anon-null object. |
NullComparator | public NullComparator(Comparator nonNullComparator, boolean nullsAreHigh)(Code) | | Construct an instance that sorts null higher or lower than
any non-null object it is compared with. When comparing
two non-null objects, the specified
Comparator is
used.
Parameters: nonNullComparator - the comparator to use when comparing twonon-null objects. This argument cannot benull Parameters: nullsAreHigh - a true value indicates thatnull should be compared as higher than anon-null object. A false value indicatesthat null should be compared as lower than anon-null object. exception: NullPointerException - if nonNullComparator isnull |
compare | public int compare(Object o1, Object o2)(Code) | | Perform a comparison between two objects. If both objects are
null , a 0 value is returned. If one object
is null and the other is not, the result is determined on
whether the Comparator was constructed to have nulls as higher or lower
than other objects. If neither object is null , an
underlying comparator specified in the constructor (or the default) is
used to compare the non-null objects.
Parameters: o1 - the first object to compare Parameters: o2 - the object to compare it to. -1 if o1 is "lower" than (less than,before, etc.) o2 ; 1 if o1 is"higher" than (greater than, after, etc.) o2 ; or0 if o1 and o2 are equal. |
equals | public boolean equals(Object obj)(Code) | | Determines whether the specified object represents a comparator that is
equal to this comparator.
Parameters: obj - the object to compare this comparator with. true if the specified object is a NullComparatorwith equivalent null comparison behavior(i.e. null high or low) and with equivalent underlyingnon-null object comparators. |
|
|