private int compareTo(final ServiceName o, final int remainingLength) { if (this == o) { return 0; } else if (remainingLength == 0) { return name.compareTo(o.name); } else { int res = parent.compareTo(o.parent, remainingLength - 1); return res == 0 ? name.compareTo(o.name) : res; } }
private int compareTo(final ServiceName o, final int remainingLength) { if (this == o) { return 0; } else if (remainingLength == 0) { return name.compareTo(o.name); } else { int res = parent.compareTo(o.parent, remainingLength - 1); return res == 0 ? name.compareTo(o.name) : res; } }
/** * Compare two service names lexicographically. * * @param o the other name * @return -1 if this name collates before the argument, 1 if it collates after, or 0 if they are equal */ public int compareTo(final ServiceName o) { if (o == null) { throw new IllegalArgumentException("o is null"); } if (this == o) return 0; final int length1 = length(); final int length2 = o.length(); int res; if (length1 == length2) { return compareTo(o, length1 - 1); } int diff = length1 - length2; if (diff > 0) { ServiceName x; for (x = this; diff > 0; diff--) { x = x.parent; } res = x.compareTo(o, length2 - 1); return res == 0 ? 1 : res; } else { return - o.compareTo(this); } }
/** * Compare two service names lexicographically. * * @param o the other name * @return -1 if this name collates before the argument, 1 if it collates after, or 0 if they are equal */ public int compareTo(final ServiceName o) { if (o == null) { throw new IllegalArgumentException("o is null"); } if (this == o) return 0; final int length1 = length(); final int length2 = o.length(); int res; if (length1 == length2) { return compareTo(o, length1 - 1); } int diff = length1 - length2; if (diff > 0) { ServiceName x; for (x = this; diff > 0; diff--) { x = x.parent; } res = x.compareTo(o, length2 - 1); return res == 0 ? 1 : res; } else { return - o.compareTo(this); } }