add warning to manage nodes dialog
[jSite2.git] / src / net / pterodactylus / jsite / core / Node.java
index 3766498..b3a98e9 100644 (file)
@@ -21,7 +21,7 @@ package net.pterodactylus.jsite.core;
 
 /**
  * Container for a Freenet node.
- * 
+ *
  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
  * @version $Id$
  */
@@ -38,7 +38,7 @@ public class Node {
 
        /**
         * Returns the user-given name of the node.
-        * 
+        *
         * @return The name of the node
         */
        public String getName() {
@@ -47,7 +47,7 @@ public class Node {
 
        /**
         * Sets the user-given name of the node.
-        * 
+        *
         * @param name
         *            The name of the node
         */
@@ -57,7 +57,7 @@ public class Node {
 
        /**
         * Returns the hostname of the node.
-        * 
+        *
         * @return The hostname of the node
         */
        public String getHostname() {
@@ -66,7 +66,7 @@ public class Node {
 
        /**
         * Sets the hostname of the node.
-        * 
+        *
         * @param hostname
         *            The hostname of the node
         */
@@ -76,7 +76,7 @@ public class Node {
 
        /**
         * Returns the port number of the node.
-        * 
+        *
         * @return The port number of the node
         */
        public int getPort() {
@@ -85,7 +85,7 @@ public class Node {
 
        /**
         * Sets the port number of the node.
-        * 
+        *
         * @param port
         *            The port number of the node
         */
@@ -93,4 +93,25 @@ public class 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)) + ")";
+       }
+
 }