summaryrefslogtreecommitdiff
path: root/src/common/PeerInformation.java
blob: 5721e35e8be9f99a26f06c77ca6c427daa6366b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package common;
import java.io.*;
import java.net.*;

public class PeerInformation implements Serializable {
	private static final long serialVersionUID = 3667108226485766929L;
	public static final String DEFAULT_ID = "something unique";

	public InetAddress address;
	public int port;
	public PeerCoordinates location;
	public String id;	
	
	public PeerInformation() {
		id = DEFAULT_ID;
	}

	public PeerInformation(PeerInformation other) {
		this(other.address, other.port, other.location);
	}
	
	public PeerInformation(InetAddress address, int port, PeerCoordinates location) {
		this();
		this.address = address;
		this.port = port;
		this.location = location;
	}
	
	public String toString() {
		return address + ":" + port + " @ " + location;
	}

	public boolean equals(Object other) {
		if (!(other instanceof PeerInformation))
			return false;
		
		return location.equals(((PeerInformation)other).location);
	}
}