public int compareTo ( Address o ) { int h1 , h2 , rc ; // added Nov 7 2005, makes sense with canonical addresses if ( this == o ) return 0 ; if ( ! ( o instanceof IpAddress ) ) throw new ClassCastException ( "comparison between different classes: the other object is " + ( o != null ? o . getClass ( ) : o ) ) ; IpAddress other = ( IpAddress ) o ; if ( ip_addr == null ) if ( other . ip_addr == null ) return port < other . port ? - 1 : ( port > other . port ? 1 : 0 ) ; else return - 1 ; h1 = ip_addr . hashCode ( ) ; h2 = other . ip_addr . hashCode ( ) ; rc = h1 < h2 ? - 1 : h1 > h2 ? 1 : 0 ; return rc != 0 ? rc : port < other . port ? - 1 : ( port > other . port ? 1 : 0 ) ; }
implements the java . lang . Comparable interface