org.sandev.basics.util
Class ExistingIDOrderComparator
java.lang.Object
org.sandev.basics.util.ExistingIDOrderComparator
- All Implemented Interfaces:
- java.util.Comparator
public class ExistingIDOrderComparator
- extends java.lang.Object
- implements java.util.Comparator
Compares two SandPersistMessages based on a prior existing ordering
with new instances either less than or greater than all previous.
So for example if you have a SandPersistMessage[] from a query, and
you want to order it based on some ordering that you had previously
defined, with any new stuff in front, then this is a way.
|
Field Summary |
protected long[] |
ids
The previous uid order we should use for reference. |
protected boolean |
prepend
If true, then anything not found in the ids will be considered
less than anything that is found in the ids. |
|
Method Summary |
int |
compare(java.lang.Object obj1,
java.lang.Object obj2)
Compare two SandPersistMessage based on their relative uid
placement within the array given for initialization. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Comparator |
equals |
ids
protected long[] ids
- The previous uid order we should use for reference.
prepend
protected boolean prepend
- If true, then anything not found in the ids will be considered
less than anything that is found in the ids. This will result
in them being sorted ahead of existing entries.
ExistingIDOrderComparator
public ExistingIDOrderComparator(long[] ids,
boolean prepend)
- Create a new comparator instance
compare
public int compare(java.lang.Object obj1,
java.lang.Object obj2)
- Compare two SandPersistMessage based on their relative uid
placement within the array given for initialization.
- Specified by:
compare in interface java.util.Comparator