KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > net > core > ConnectionInfo


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.net.core;
5
6 import com.tc.util.Assert;
7
8 public class ConnectionInfo implements java.io.Serializable JavaDoc {
9
10   private final String JavaDoc hostname;
11   private final int port;
12   
13   public ConnectionInfo(String JavaDoc hostname, int port) {
14     Assert.assertNotNull(hostname);
15     this.hostname = hostname;
16     this.port = port;
17   }
18   
19   public String JavaDoc getHostname() {
20     return hostname;
21   }
22   public int getPort() {
23     return port;
24   }
25   
26   public boolean equals(Object JavaDoc 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 JavaDoc s;
40   public String JavaDoc toString() {
41     return (s == null ? (s = hostname + ":" + port) : s );
42   }
43 }
44
Popular Tags