Class ListitemComparator
- All Implemented Interfaces:
Serializable,Comparator
Listitem, if not live data,
or the data themselves, if live data.- Author:
- tomyeh
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCompares withListitem.getValue().ListitemComparator(int index) Compares with the column of the specified index.ListitemComparator(int index, boolean ascending, boolean ignoreCase) Compares with the column of the specified index.ListitemComparator(int index, boolean ascending, boolean ignoreCase, boolean byValue) Compares with the column of the specified index.ListitemComparator(int index, boolean ascending, boolean ignoreCase, boolean byValue, boolean nullAsMax) Compares with the column of the specified index.ListitemComparator(Listheader header, boolean ascending, boolean ignoreCase) Compares with the column which the list header is at.ListitemComparator(Listheader header, boolean ascending, boolean ignoreCase, boolean byValue) Compares with the column which the list header is at.ListitemComparator(Listheader header, boolean ascending, boolean ignoreCase, boolean byValue, boolean nullAsMax) Compares with the column which the list header is at. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbyValue()Returns whether to compare the returned value ofListcell.getValue()intbooleanReturns the listheader that this comparator is associated with, or null if not available.inthashCode()booleanReturns whether the order is ascending.booleanReturns whether to ignore case.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
ListitemComparator
public ListitemComparator()Compares withListitem.getValue().It assumes the value returned by
Listitem.getValue()implements Comparable.Note: It assumes the ascending order and case-insensitive. If not, use
ListitemComparator(int, boolean, boolean)instead. -
ListitemComparator
public ListitemComparator(int index) Compares with the column of the specified index.0 for the first column, 1 for the second and so on
Note: -1 for
Listitem.getValue()and it assumes the value implements Comparable.Note: It assumes the ascending order, case-insensitive and comparing the returned values of
LabelElement.getLabel(). If not, useListitemComparator(int, boolean, boolean, boolean)instead.A null value is considered as the minimum value.
- Parameters:
index- which column to compare. If -1,Listitem.getValue()is used.
-
ListitemComparator
public ListitemComparator(int index, boolean ascending, boolean ignoreCase) Compares with the column of the specified index.0 for the first column, 1 for the second and so on
Note: -1 for
Listitem.getValue()and it assumes the value implements Comparable.Note: it compares the returned value of
LabelElement.getLabel(). If you want to compareListcell.getValue()., useListitemComparator(int, boolean, boolean, boolean)instead.A null value is considered as the minimum value.
- Parameters:
index- which column to compare. If -1,Listitem.getValue()is used.ascending- whether to sort as ascending (or descending).ignoreCase- whether to sort case-insensitive
-
ListitemComparator
public ListitemComparator(int index, boolean ascending, boolean ignoreCase, boolean byValue) Compares with the column of the specified index.0 for the first column, 1 for the second and so on
Note: -1 for
Listitem.getValue()and it assumes the value implements Comparable.A null value is considered as the minimum value.
- Parameters:
index- which column to compare. If -1,Listitem.getValue()is used.ascending- whether to sort as ascending (or descending).ignoreCase- whether to sort case-insensitivebyValue- whether to compareListcell.getValue(). If false, it comparesLabelElement.getLabel(). If true, it assumes the value returned byListcell.getValue()implements Comparable. It is ignored if the index is -1.
-
ListitemComparator
public ListitemComparator(int index, boolean ascending, boolean ignoreCase, boolean byValue, boolean nullAsMax) Compares with the column of the specified index.0 for the first column, 1 for the second and so on
Note: -1 for
Listitem.getValue()and it assumes the value implements Comparable.- Parameters:
index- which column to compare. If -1,Listitem.getValue()is used.ascending- whether to sort as ascending (or descending).ignoreCase- whether to sort case-insensitivebyValue- whether to compareListcell.getValue(). If false, it comparesLabelElement.getLabel(). If true, it assumes the value returned byListcell.getValue()implements Comparable. It is ignored if the index is -1.nullAsMax- whether to consider null as the maximum value. If false, null is considered as the minimum value.
-
ListitemComparator
Compares with the column which the list header is at.Note: it compares the returned value of
LabelElement.getLabel(). If you want to compareListcell.getValue()., useListitemComparator(Listheader, boolean, boolean, boolean)instead.A null value is considered as the minimum value.
- Parameters:
ascending- whether to sort as ascending (or descending).ignoreCase- whether to sort case-insensitive
-
ListitemComparator
public ListitemComparator(Listheader header, boolean ascending, boolean ignoreCase, boolean byValue) Compares with the column which the list header is at.A null value is considered as the minimum value.
- Parameters:
ascending- whether to sort as ascending (or descending).ignoreCase- whether to sort case-insensitivebyValue- whether to compareListcell.getValue(). If false, it comparesLabelElement.getLabel().
-
ListitemComparator
public ListitemComparator(Listheader header, boolean ascending, boolean ignoreCase, boolean byValue, boolean nullAsMax) Compares with the column which the list header is at.- Parameters:
ascending- whether to sort as ascending (or descending).ignoreCase- whether to sort case-insensitivebyValue- whether to compareListcell.getValue(). If false, it comparesLabelElement.getLabel().nullAsMax- whether to consider null as the maximum value. If false, null is considered as the minimum value.
-
-
Method Details
-
getListheader
Returns the listheader that this comparator is associated with, or null if not available. -
isAscending
public boolean isAscending()Returns whether the order is ascending. -
shallIgnoreCase
public boolean shallIgnoreCase()Returns whether to ignore case. -
byValue
public boolean byValue()Returns whether to compare the returned value ofListcell.getValue() -
compare
- Specified by:
comparein interfaceComparator
-
equals
- Specified by:
equalsin interfaceComparator- Overrides:
equalsin classObject
-
hashCode
public int hashCode() -
toString
-