public class BooleanComparator
extends java.lang.Object
implements java.util.Comparator<java.lang.Boolean>, java.io.Serializable
Comparator
for Boolean
objects that can sort either
true
or false
first.Modifier and Type | Field and Description |
---|---|
static BooleanComparator |
TRUE_HIGH
A shared default instance of this comparator,
treating
true higher than false . |
static BooleanComparator |
TRUE_LOW
A shared default instance of this comparator,
treating
true lower than false . |
Constructor and Description |
---|
BooleanComparator(boolean trueLow)
Create a BooleanComparator that sorts boolean values based on
the provided flag.
|
Modifier and Type | Method and Description |
---|---|
int |
compare(java.lang.Boolean v1,
java.lang.Boolean v2) |
boolean |
equals(java.lang.Object other) |
int |
hashCode() |
java.lang.String |
toString() |
public static final BooleanComparator TRUE_LOW
true
lower than false
.public static final BooleanComparator TRUE_HIGH
true
higher than false
.public BooleanComparator(boolean trueLow)
Alternatively, you can use the default shared instances:
BooleanComparator.TRUE_LOW
and
BooleanComparator.TRUE_HIGH
.
public int compare(java.lang.Boolean v1, java.lang.Boolean v2)
compare
in interface java.util.Comparator<java.lang.Boolean>
public boolean equals(java.lang.Object other)
equals
in interface java.util.Comparator<java.lang.Boolean>
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object