Proper LocalAddress.compareTo() implementation

This commit is contained in:
Trustin Lee 2010-04-12 10:36:04 +00:00
parent d0d2519871
commit 2fc539a9bc

View File

@ -101,9 +101,28 @@ public final class LocalAddress extends SocketAddress implements Comparable<Loca
}
public int compareTo(LocalAddress o) {
// FIXME: Ephemeral port
if (ephemeral) {
if (o.ephemeral) {
int a = System.identityHashCode(this);
int b = System.identityHashCode(this);
if (a < b) {
return -1;
} else if (a > b) {
return 1;
} else {
return 0;
}
} else {
return -1;
}
} else {
if (o.ephemeral) {
return 1;
} else {
return getId().compareTo(o.getId());
}
}
}
@Override
public String toString() {