Fixed ProtectedRegion.compareTo.

It properly implements the Comparable interface now.
In particular, it now fulfills the criterion "sgn(x.compareTo(y)) == -sgn(y.compareTo(x))".
This commit is contained in:
TomyLobo 2012-01-09 14:47:59 +01:00
parent 46a2510e85
commit 9d848e222b

View File

@ -414,21 +414,22 @@ public boolean containsAny(List<BlockVector2D> pts) {
}
/**
* Compares to another region.
* Compares to another region.<br>
*<br>
* Orders primarily by the priority, descending<br>
* Orders secondarily by the id, ascending
*
* @param other
* @return
*/
public int compareTo(ProtectedRegion other) {
if (id.equals(other.id)) {
return 0;
} else if (priority == other.priority) {
return 1;
} else if (priority > other.priority) {
if (priority > other.priority) {
return -1;
} else {
} else if (priority < other.priority) {
return 1;
}
return id.compareTo(other.id);
}
/**