Class BooleanComparator
java.lang.Object
org.apache.commons.collections.comparators.BooleanComparator
- All Implemented Interfaces:
Serializable,Comparator
@Deprecated(since="2021-04-30")
public final class BooleanComparator
extends Object
implements Comparator, Serializable
Deprecated.
Apache Commons Collections version 3.x is being deprecated from AEMaaCS. The upgraded version 4.4 of Commons Collections is already included as replacement. Customers are advised to upgrade to this version of the library. Please note: the package name was changed to org.apache.commons.collections4. Further note that there are AEM APIs currently exposing the old collections classes; these will be updated in upcoming releases.
A
Comparator for Boolean objects that can sort either
true or false first.
- Since:
- Commons Collections 3.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Creates aBooleanComparatorthat sortsfalsevalues beforetruevalues.BooleanComparator(boolean trueFirst) Deprecated.Creates aBooleanComparatorthat sortstrueFirstvalues before!trueFirstvalues. -
Method Summary
Modifier and TypeMethodDescriptionintDeprecated.intDeprecated.Compares two arbitrary Objects.booleanDeprecated.Returnstrueiff that Object is is aComparatorwhose ordering is known to be equivalent to mine.static BooleanComparatorgetBooleanComparator(boolean trueFirst) Deprecated.Returns a BooleanComparator instance that sortstrueFirstvalues before!trueFirstvalues.static BooleanComparatorDeprecated.Returns a BooleanComparator instance that sortsfalsevalues beforetruevalues.static BooleanComparatorDeprecated.Returns a BooleanComparator instance that sortstruevalues beforefalsevalues.inthashCode()Deprecated.Implement a hash code for this comparator that is consistent withequals.booleanDeprecated.Returnstrueiff I sorttruevalues beforefalsevalues.Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
BooleanComparator
public BooleanComparator()Deprecated.Creates aBooleanComparatorthat sortsfalsevalues beforetruevalues.Equivalent to
BooleanComparator(false).Please use the static factory instead whenever possible.
-
BooleanComparator
public BooleanComparator(boolean trueFirst) Deprecated.Creates aBooleanComparatorthat sortstrueFirstvalues before!trueFirstvalues.Please use the static factories instead whenever possible.
- Parameters:
trueFirst- whentrue, sorttrueboolean values beforefalse
-
-
Method Details
-
getTrueFirstComparator
Deprecated.Returns a BooleanComparator instance that sortstruevalues beforefalsevalues. 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.- Returns:
- the true first singleton BooleanComparator
-
getFalseFirstComparator
Deprecated.Returns a BooleanComparator instance that sortsfalsevalues beforetruevalues. 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.- Returns:
- the false first singleton BooleanComparator
-
getBooleanComparator
Deprecated.Returns a BooleanComparator instance that sortstrueFirstvalues before!trueFirstvalues. 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.- Parameters:
trueFirst- whentrue, sorttrueBooleans beforefalse- Returns:
- a singleton BooleanComparator instance
-
compare
Deprecated.Compares two arbitrary Objects. When both arguments areBoolean, this method is equivalent tocompare((Boolean)obj1,(Boolean)obj2). When either argument is not aBoolean, this methods throws aClassCastException.- Specified by:
comparein interfaceComparator- Parameters:
obj1- the first object to compareobj2- the second object to compare- Returns:
- negative if obj1 is less, positive if greater, zero if equal
- Throws:
ClassCastException- when either argument is notBoolean
-
compare
Deprecated.- Parameters:
b1- the first boolean to compareb2- the second boolean to compare- Returns:
- negative if obj1 is less, positive if greater, zero if equal
- Throws:
NullPointerException- when either argumentnull
-
hashCode
public int hashCode()Deprecated.Implement a hash code for this comparator that is consistent withequals. -
equals
Deprecated.Returnstrueiff that Object is is aComparatorwhose ordering is known to be equivalent to mine.This implementation returns
trueiffthatis aBooleanComparatorwhose value ofsortsTrueFirst()is equal to mine.- Specified by:
equalsin interfaceComparator- Overrides:
equalsin classObject- Parameters:
object- the object to compare to- Returns:
- true if equal
-
sortsTrueFirst
public boolean sortsTrueFirst()Deprecated.Returnstrueiff I sorttruevalues beforefalsevalues. In other words, returnstrueiffcompare(Boolean.FALSE,Boolean.TRUE)returns a positive value.- Returns:
- the trueFirst flag
-