/**
* Container for a Freenet node.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
*/
/**
* Returns the user-given name of the node.
- *
+ *
* @return The name of the node
*/
public String getName() {
/**
* Sets the user-given name of the node.
- *
+ *
* @param name
* The name of the node
*/
/**
* Returns the hostname of the node.
- *
+ *
* @return The hostname of the node
*/
public String getHostname() {
/**
* Sets the hostname of the node.
- *
+ *
* @param hostname
* The hostname of the node
*/
/**
* Returns the port number of the node.
- *
+ *
* @return The port number of the node
*/
public int getPort() {
/**
* Sets the port number of the node.
- *
+ *
* @param port
* The port number of the node
*/
this.port = port;
}
+ /**
+ * {@inheritDoc} Two Node objects are considered equal if their hostnames
+ * and their port numbers are equal.
+ */
+ @Override
+ public boolean equals(Object object) {
+ if ((object == null) || !(object instanceof Node)) {
+ return false;
+ }
+ Node node = (Node) object;
+ return hostname.equals(node.hostname) && port == node.port;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return name + " (" + hostname + ((port == 9481) ? ("") : (":" + port)) + ")";
+ }
+
}