|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.collections.comparators.NullComparator
public class NullComparator
A Comparator that will compare nulls to be either lower or higher than other objects.
| Constructor Summary | |
|---|---|
NullComparator()
Construct an instance that sorts null higher than any
non-null object it is compared with. |
|
NullComparator(boolean nullsAreHigh)
Construct an instance that sorts null higher or lower than
any non-null object it is compared with. |
|
NullComparator(java.util.Comparator nonNullComparator)
Construct an instance that sorts null higher than any
non-null object it is compared with. |
|
NullComparator(java.util.Comparator nonNullComparator,
boolean nullsAreHigh)
Construct an instance that sorts null higher or lower than
any non-null object it is compared with. |
|
| Method Summary | |
|---|---|
int |
compare(java.lang.Object o1,
java.lang.Object o2)
Perform a comparison between two objects. |
boolean |
equals(java.lang.Object obj)
Determines whether the specified object represents a comparator that is equal to this comparator. |
int |
hashCode()
Implement a hash code for this comparator that is consistent with equals(Object). |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NullComparator()
null higher than any
non-null object it is compared with. When comparing two
non-null objects, the ComparableComparator is
used.
public NullComparator(java.util.Comparator nonNullComparator)
null higher than any
non-null object it is compared with. When comparing two
non-null objects, the specified Comparator is
used.
nonNullComparator - the comparator to use when comparing two
non-null objects. This argument cannot be
null
java.lang.NullPointerException - if nonNullComparator is
nullpublic NullComparator(boolean nullsAreHigh)
null higher or lower than
any non-null object it is compared with. When comparing
two non-null objects, the ComparableComparator is
used.
nullsAreHigh - a true value indicates that
null should be compared as higher than a
non-null object. A false value indicates
that null should be compared as lower than a
non-null object.
public NullComparator(java.util.Comparator nonNullComparator,
boolean nullsAreHigh)
null higher or lower than
any non-null object it is compared with. When comparing
two non-null objects, the specified Comparator is
used.
nonNullComparator - the comparator to use when comparing two
non-null objects. This argument cannot be
nullnullsAreHigh - a true value indicates that
null should be compared as higher than a
non-null object. A false value indicates
that null should be compared as lower than a
non-null object.
java.lang.NullPointerException - if nonNullComparator is
null| Method Detail |
|---|
public int compare(java.lang.Object o1,
java.lang.Object o2)
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.
compare in interface java.util.Comparatoro1 - the first object to compareo2 - 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; or
0 if o1 and o2 are equal.public int hashCode()
equals(Object).
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in interface java.util.Comparatorequals in class java.lang.Objectobj - the object to compare this comparator with.
true if the specified object is a NullComparator
with equivalent null comparison behavior
(i.e. null high or low) and with equivalent underlying
non-null object comparators.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||