public class ListComparator
extends java.lang.Object
implements java.util.Comparator
Modifier and Type | Field and Description |
---|---|
protected java.util.List |
comparatorListObj |
protected int |
comparatorListSize |
Constructor and Description |
---|
ListComparator(java.util.List listObj)
Creates a comparator that determines order using the given list
of objects.
|
ListComparator(java.lang.Object[] objArr)
Creates a comparator that determines order using the given array
of objects.
|
Modifier and Type | Method and Description |
---|---|
int |
compare(java.lang.Object obj1,
java.lang.Object obj2)
Compares its two arguments for order via their position in the
list.
|
boolean |
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this
Comparator.
|
protected final java.util.List comparatorListObj
protected final int comparatorListSize
public ListComparator(java.util.List listObj)
listObj
- the list of objects to use.public ListComparator(java.lang.Object[] objArr)
objArr
- the array of objects to use.public int compare(java.lang.Object obj1, java.lang.Object obj2)
compare
in interface java.util.Comparator
obj1
- the first object to be compared.obj2
- the second object to be compared.java.lang.ClassCastException
- if the arguments' types prevent them
from being compared by this Comparator.public boolean equals(java.lang.Object obj)
equals
in interface java.util.Comparator
equals
in class java.lang.Object
obj
- the reference object with which to compare.true
only if the specified object is also
a comparator and it imposes the same ordering as this
comparator.