Code example for InetAddress

Methods: hashCode

0
 
  @Override 
  public int hashCode() { 
    int code = 7;
    code = code * 31 + (name != null ? name.hashCode() : 0);
    code = code * 31 + (address != null ? address.hashCode() : 0);
    code = code * 31 + port;
    return code;
  } 
 
  @Override 
  public String toString() {
    return String.format("%s [%s:%d]", name, address, port);
  } 
 
  private static <T> boolean equal(T obj1, T obj2) {
    if (obj1 == null) {
      return obj2 == null;
    } 
    return obj1.equals(obj2);
  }