|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.collections15.comparators.BooleanComparator
public final class BooleanComparator
A Comparator
for Boolean
objects that can sort either
true
or false
first.
getTrueFirstComparator()
,
getFalseFirstComparator()
,
getInstance(boolean)
,
Serialized FormConstructor Summary | |
---|---|
protected |
BooleanComparator(boolean trueFirst)
Creates a BooleanComparator that sorts
trueFirst values before !trueFirst values. |
Method Summary | |
---|---|
int |
compare(java.lang.Boolean b1,
java.lang.Boolean b2)
Compares two non- null Boolean objects according
to the value of trueFirst . |
boolean |
equals(java.lang.Object object)
Compares this comparator to a specified object. |
static BooleanComparator |
getFalseFirstComparator()
Returns a BooleanComparator instance that sorts
false values before true values. |
static BooleanComparator |
getInstance(boolean trueFirst)
Returns a BooleanComparator instance with the specified
sorting order. |
static BooleanComparator |
getTrueFirstComparator()
Returns a BooleanComparator instance that sorts
true values before false values. |
int |
hashCode()
Implements a hash code for this comparator that is consistent with equals . |
boolean |
sortsTrueFirst()
Returns true only if this Boolean comparator
instance sorts true values before false values. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected BooleanComparator(boolean trueFirst)
BooleanComparator
that sorts
trueFirst
values before !trueFirst
values.
trueFirst
- If true
the Comparator
sorts
true
before false. If
false
, the Comparator
sorts
false
before true
.Method Detail |
---|
public static BooleanComparator getTrueFirstComparator()
BooleanComparator
instance that sorts
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.
Comparator
that sorts true
before
false
.public static BooleanComparator getFalseFirstComparator()
BooleanComparator
instance that sorts
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.
Comparator
that sorts false
before
true
.public static BooleanComparator getInstance(boolean trueFirst)
BooleanComparator
instance with the specified
sorting order.
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.
trueFirst
- If true
the Comparator
instance returned sorts true
before
false. If false
, the returned
instances sorts false
before
true
.
Comparator
with the specified sorting order.public int compare(java.lang.Boolean b1, java.lang.Boolean b2)
null
Boolean
objects according
to the value of trueFirst
.
compare
in interface java.util.Comparator<java.lang.Boolean>
b1
- The first boolean to compare.b2
- The second boolean to compare.
b1
is less than b2
,
a positive value if b1
is greater than
b2
, or zero if b1
and b2
are equal.
java.lang.NullPointerException
- if either argument null
.public int hashCode()
equals
.
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object object)
equals
in interface java.util.Comparator<java.lang.Boolean>
equals
in class java.lang.Object
object
- The object to compare to.
true
only if object
is a
BooleanComparator
whose trueFirst
value is
equal to this BooleanComparator
's value.public boolean sortsTrueFirst()
true
only if this Boolean
comparator
instance sorts true
values before false
values.
In other words, returns true
only if compare(Boolean.FALSE,Boolean.TRUE)
returns a
positive value.
trueFirst
flag.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |