com.databasesandlife.util.UuidTreeSet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-common Show documentation
Show all versions of java-common Show documentation
Utility classes developed at Adrian Smith Software (A.S.S.)
package com.databasesandlife.util;
import java.util.Collection;
import java.util.Comparator;
import java.util.TreeSet;
import java.util.UUID;
/**
* This is an ordered set of UUIDs.
* Unfortunately a standard TreeSet of UUIDs is broken, it puts them in the wrong order,
* see this Java bug which is marked "will not fix".
*
* @author This source is copyright Adrian Smith and licensed under the LGPL 3.
* @see Project on GitHub
*/
public class UuidTreeSet extends TreeSet {
public static class UuidComparator implements Comparator {
@Override public int compare(UUID o1, UUID o2) {
return o1.toString().compareTo(o2.toString());
}
}
public UuidTreeSet() {
super(new UuidComparator());
}
public UuidTreeSet(Collection extends UUID> values) {
this();
addAll(values);
}
}