create new id if null id is set
[jSite2.git] / src / net / pterodactylus / jsite / core / Node.java
index bb61ee9..9a4d3be 100644 (file)
@@ -77,7 +77,11 @@ public class Node extends AbstractBean {
         *            The internal ID of the node
         */
        void setId(String id) {
-               this.id = id;
+               if (id == null) {
+                       this.id = Hex.toHex(IdGenerator.generateId());
+               } else {
+                       this.id = id;
+               }
        }
 
        /**
@@ -148,7 +152,7 @@ public class Node extends AbstractBean {
         */
        @Override
        public String toString() {
-               return name + " (" + hostname + ((port == 9481) ? ("") : (":" + port)) + ")";
+               return getClass().getName() + "[name=" + name + ",hostname=" + hostname + ",port=" + port + "]";
        }
 
 }