1 4 package com.tc.net.core; 5 6 import com.tc.util.Assert; 7 8 public class ConnectionInfo implements java.io.Serializable { 9 10 private final String hostname; 11 private final int port; 12 13 public ConnectionInfo(String hostname, int port) { 14 Assert.assertNotNull(hostname); 15 this.hostname = hostname; 16 this.port = port; 17 } 18 19 public String getHostname() { 20 return hostname; 21 } 22 public int getPort() { 23 return port; 24 } 25 26 public boolean equals(Object o) { 27 if(o == this) return true; 28 if(o instanceof ConnectionInfo) { 29 ConnectionInfo other = (ConnectionInfo)o; 30 return this.hostname.equals(other.getHostname()) && this.port == other.getPort() ; 31 } 32 return false; 33 } 34 35 public int hashCode() { 36 return toString().hashCode(); 37 } 38 39 private String s; 40 public String toString() { 41 return (s == null ? (s = hostname + ":" + port) : s ); 42 } 43 } 44 | Popular Tags |