root / src / chord / ConnectionInfo.java
History | View | Annotate | Download (1.19 KB)
1 |
package chord; |
---|---|
2 |
|
3 |
import java.io.Serializable; |
4 |
import java.math.BigInteger; |
5 |
|
6 |
public class ConnectionInfo implements Serializable { |
7 |
|
8 |
private String ip; |
9 |
private int port; |
10 |
private BigInteger hashedKey; |
11 |
|
12 |
public ConnectionInfo(BigInteger hashedKey, String ip, int port) { |
13 |
this.ip = ip;
|
14 |
this.port = port;
|
15 |
this.hashedKey = hashedKey;
|
16 |
} |
17 |
|
18 |
public String getIp() { |
19 |
return ip;
|
20 |
} |
21 |
|
22 |
public void setIp(String ip) { |
23 |
this.ip = ip;
|
24 |
} |
25 |
|
26 |
public int getPort() { |
27 |
return port;
|
28 |
} |
29 |
|
30 |
public void setPort(int port) { |
31 |
this.port = port;
|
32 |
} |
33 |
|
34 |
@Override
|
35 |
public String toString() { |
36 |
if(this.getHashedKey() != null) |
37 |
return this.hashedKey + " " + this.ip + " " + this.port; |
38 |
else
|
39 |
return this.ip + " " + this.port; |
40 |
} |
41 |
|
42 |
@Override
|
43 |
public boolean equals(Object obj) { |
44 |
if(obj instanceof ConnectionInfo){ |
45 |
ConnectionInfo ci = (ConnectionInfo) obj; |
46 |
return (this.hashedKey.equals(ci.getHashedKey()) && this.port == ci.getPort() && this.ip.equals(ci.getIp())); |
47 |
} |
48 |
return false; |
49 |
} |
50 |
|
51 |
public BigInteger getHashedKey() { |
52 |
return hashedKey;
|
53 |
} |
54 |
} |