01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.net.core;
06:
07: import com.tc.util.Assert;
08:
09: public class ConnectionInfo implements java.io.Serializable {
10:
11: public static final ConnectionInfo[] EMPTY_ARRAY = new ConnectionInfo[0];
12: private final String hostname;
13: private final int port;
14:
15: public ConnectionInfo(String hostname, int port) {
16: Assert.assertNotNull(hostname);
17: this .hostname = hostname;
18: this .port = port;
19: }
20:
21: public String getHostname() {
22: return hostname;
23: }
24:
25: public int getPort() {
26: return port;
27: }
28:
29: public boolean equals(Object o) {
30: if (o == this )
31: return true;
32: if (o instanceof ConnectionInfo) {
33: ConnectionInfo other = (ConnectionInfo) o;
34: return this .hostname.equals(other.getHostname())
35: && this .port == other.getPort();
36: }
37: return false;
38: }
39:
40: public int hashCode() {
41: return toString().hashCode();
42: }
43:
44: private String s;
45:
46: public String toString() {
47: return (s == null ? (s = hostname + ":" + port) : s);
48: }
49: }
|