java.lang.Object | +--org.apache.commons.collections.comparators.BooleanComparatorAll Implemented Interfaces:
getTrueFirstComparator
getFalseFirstComparator
getBooleanComparator
Creates a BooleanComparator that sorts false values before true values. |
BooleanComparator(boolean trueFirst) Creates a BooleanComparator that sorts trueFirst values before !trueFirst values. |
int | compare(Object o1, Object o2) Compares two arbitrary Objects. |
int | compare(Boolean b1, Boolean b2) Compares two non-nullBooleans according to the value of #sortsTrueFirst. |
boolean | equals(Object that) Returns true iff that Object is is a Comparator whose ordering is known to be equivalent to mine. |
static BooleanComparator | getBooleanComparator(boolean trueFirst) Returns a BooleanComparator instance that sorts trueFirst values before !trueFirst values. |
static BooleanComparator | Returns a BooleanComparator instance that sorts false values before true values. |
static BooleanComparator | Returns a BooleanComparator instance that sorts true values before false values. |
int | hashCode() Implement a hash code for this comparator that is consistent with #equals equals. |
boolean | Returns true iff I sort true values before false values. |
public BooleanComparator()
BooleanComparator
that sorts false
values before
true
values.
Equivalent to BooleanComparator(boolean) BooleanComparator(false).
public BooleanComparator(boolean trueFirst)
BooleanComparator
that sorts trueFirst
values before
!trueFirst
values.
public int compare(Boolean b1, Boolean b2)
null
Booleans
according to the value of sortsTrueFirst.
- when either argument nullpublic int compare(Object o1, Object o2)
- when either argument is not
a Booleanpublic boolean equals(Object that)
true
iff that Object is
is a Comparator whose ordering is known to be
equivalent to mine.
This implementation returns true
iff that
is a BooleanComparator
whose sortsTrueFirst value is equal to mine.
public static BooleanComparator getBooleanComparator(boolean trueFirst)
trueFirst
values before
!trueFirst
values.
Clients are encouraged to use the value returned from
this method instead of constructing a new instance
to reduce allocation and garbage collection overhead when
multiple BooleanComparators may be used in the same
virtual machine.
public static BooleanComparator getFalseFirstComparator()
false
values before true
values.
Clients are encouraged to use the value returned from
this method instead of constructing a new instance
to reduce allocation and garbage collection overhead when
multiple BooleanComparators may be used in the same
virtual machine.
public static BooleanComparator getTrueFirstComparator()
true
values before false
values.
Clients are encouraged to use the value returned from
this method instead of constructing a new instance
to reduce allocation and garbage collection overhead when
multiple BooleanComparators may be used in the same
virtual machine.
public int hashCode()
public boolean sortsTrueFirst()
true
iff
I sort true
values before
false
values. In other words,
returns true
iff
compare(Boolean,Boolean) compare(Boolean.FALSE,Boolean.TRUE)
returns a positive value.