Class NullComparator
java.lang.Object
org.apache.commons.collections.comparators.NullComparator
- All Implemented Interfaces:
Serializable,Comparator
@Deprecated(since="2021-04-30")
public class NullComparator
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 that will compare nulls to be either lower or higher than
other objects.
- Since:
- Commons Collections 2.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Construct an instance that sortsnullhigher than any non-nullobject it is compared with.NullComparator(boolean nullsAreHigh) Deprecated.Construct an instance that sortsnullhigher or lower than any non-nullobject it is compared with.NullComparator(Comparator nonNullComparator) Deprecated.Construct an instance that sortsnullhigher than any non-nullobject it is compared with.NullComparator(Comparator nonNullComparator, boolean nullsAreHigh) Deprecated.Construct an instance that sortsnullhigher or lower than any non-nullobject it is compared with. -
Method Summary
Modifier and TypeMethodDescriptionintDeprecated.Perform a comparison between two objects.booleanDeprecated.Determines whether the specified object represents a comparator that is equal to this comparator.inthashCode()Deprecated.Implement a hash code for this comparator that is consistent withequals(Object).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
-
NullComparator
public NullComparator()Deprecated.Construct an instance that sortsnullhigher than any non-nullobject it is compared with. When comparing two non-nullobjects, theComparableComparatoris used. -
NullComparator
Deprecated.Construct an instance that sortsnullhigher than any non-nullobject it is compared with. When comparing two non-nullobjects, the specifiedComparatoris used.- Parameters:
nonNullComparator- the comparator to use when comparing two non-nullobjects. This argument cannot benull- Throws:
NullPointerException- ifnonNullComparatorisnull
-
NullComparator
public NullComparator(boolean nullsAreHigh) Deprecated.Construct an instance that sortsnullhigher or lower than any non-nullobject it is compared with. When comparing two non-nullobjects, theComparableComparatoris used.- Parameters:
nullsAreHigh- atruevalue indicates thatnullshould be compared as higher than a non-nullobject. Afalsevalue indicates thatnullshould be compared as lower than a non-nullobject.
-
NullComparator
Deprecated.Construct an instance that sortsnullhigher or lower than any non-nullobject it is compared with. When comparing two non-nullobjects, the specifiedComparatoris used.- Parameters:
nonNullComparator- the comparator to use when comparing two non-nullobjects. This argument cannot benullnullsAreHigh- atruevalue indicates thatnullshould be compared as higher than a non-nullobject. Afalsevalue indicates thatnullshould be compared as lower than a non-nullobject.- Throws:
NullPointerException- ifnonNullComparatorisnull
-
-
Method Details
-
compare
Deprecated.Perform a comparison between two objects. If both objects arenull, a0value is returned. If one object isnulland 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 isnull, an underlying comparator specified in the constructor (or the default) is used to compare the non-nullobjects.- Specified by:
comparein interfaceComparator- Parameters:
o1- the first object to compareo2- the object to compare it to.- Returns:
-1ifo1is "lower" than (less than, before, etc.)o2;1ifo1is "higher" than (greater than, after, etc.)o2; or0ifo1ando2are equal.
-
hashCode
public int hashCode()Deprecated.Implement a hash code for this comparator that is consistent withequals(Object). -
equals
Deprecated.Determines whether the specified object represents a comparator that is equal to this comparator.- Specified by:
equalsin interfaceComparator- Overrides:
equalsin classObject- Parameters:
obj- the object to compare this comparator with.- Returns:
trueif the specified object is a NullComparator with equivalentnullcomparison behavior (i.e.nullhigh or low) and with equivalent underlying non-nullobject comparators.
-