Class Sort
java.lang.Object
com.inductiveautomation.snap.data.Sort
- All Implemented Interfaces:
- RMJSONArchiver.GetKeys,- Cloneable,- Comparator
This class provides a basic description for comparison and sorting with a simple key and order (ascending or
 descending). You can create a new order like this:
 
   Sort titleFirst = new Sort("Title");
   Sort bestRevenueFirst = new Sort("Revenue", ORDER_DESCEND);
 This class also provides useful static methods for comparison and sorting:
Sort.sort(myList, "Title"); // Sort myList by its contents' getTitle method (alphabetically) Sort.sort(myList, bestRevenueFirst); // Sort myList by its contents' getRevenue method (largest first) List mySortList = new ArrayList(); mySortList.add(bestRevenueFirst); mySortList.add(titleFirst); Sort.sort(myList, mySortList); // Sort myList by revenue and title
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic Comparatorstatic final bytestatic final bytestatic final byte
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionclone()Standard clone implementation.intReturns how the two given objects compare with this sort.static intCompare two value objects (assumed to be String, Number, Boolean, Date, Comparable, etc.).booleanStandard equals implementation.RMJSONArchiver GetKeys method.getKey()Returns the key for this sort.intgetOrder()Returns the order for this sort.voidSets the key for this sort.voidsetOrder(int anOrder) Sets the order for this sort.static voidReturns the given list sorted by the given sort.static voidReturns the given list sorted by the given sort.static voidReturns the given list sorted by the given key.static voidReturns the given list sorted by the given key.static voidReturns the given list sorted by the given list of sorts.static <T extends Comparable<? super T>>
 List<T>sortedList(Collection<T> aCollection) Returns a new sorted list from given collection.static <T> List<T>sortedList(Collection<T> aCollection, String aKey) Returns a new list from the given list sorted by the given key.static <T> List<T>sortedList(Collection<T> aCollection, String... theKeys) Returns a new list from the given list sorted by the given key.voidToggles the order for this sort between ORDER_ASCEND<->ORDER_DESCEND.toString()Returns a string representation of sort (just the sort key).Methods inherited from class java.lang.Objectfinalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Comparatorreversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
- 
Field Details- 
ORDER_SAMEpublic static final byte ORDER_SAME- See Also:
 
- 
ORDER_ASCENDpublic static final byte ORDER_ASCEND- See Also:
 
- 
ORDER_DESCENDpublic static final byte ORDER_DESCEND- See Also:
 
- 
COMPARATOR
 
- 
- 
Constructor Details- 
Sortpublic Sort()Creates a plain sort with no key. Used for unarchival, shouldn't be called directly.
- 
SortCreates a sort with the given key and ORDER_ASCEND.
- 
SortCreates a sort with the given key and order.
 
- 
- 
Method Details- 
getKeyReturns the key for this sort.
- 
setKeySets the key for this sort.
- 
getOrderpublic int getOrder()Returns the order for this sort.
- 
setOrderpublic void setOrder(int anOrder) Sets the order for this sort.
- 
toggleOrderpublic void toggleOrder()Toggles the order for this sort between ORDER_ASCEND<->ORDER_DESCEND.
- 
compareReturns how the two given objects compare with this sort.- Specified by:
- comparein interface- Comparator
 
- 
CompareCompare two value objects (assumed to be String, Number, Boolean, Date, Comparable, etc.).
- 
sortReturns the given list sorted by the given key.
- 
sortReturns the given list sorted by the given sort.
- 
sortReturns the given list sorted by the given key.
- 
sortReturns the given list sorted by the given sort.
- 
sortReturns the given list sorted by the given list of sorts.
- 
sortedListReturns a new sorted list from given collection.
- 
sortedListReturns a new list from the given list sorted by the given key.
- 
sortedListReturns a new list from the given list sorted by the given key.
- 
cloneStandard clone implementation.
- 
getJSONKeysRMJSONArchiver GetKeys method.- Specified by:
- getJSONKeysin interface- RMJSONArchiver.GetKeys
 
- 
equalsStandard equals implementation.- Specified by:
- equalsin interface- Comparator
- Overrides:
- equalsin class- Object
 
- 
toStringReturns a string representation of sort (just the sort key).
 
-