Implement toString method
[xudocci.git] / src / main / java / net / pterodactylus / xdcc / data / Network.java
index 8fac0ea..d78e71c 100644 (file)
 
 package net.pterodactylus.xdcc.data;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import java.util.Collection;
 
-import com.beust.jcommander.internal.Sets;
-import com.google.common.base.Objects;
+import com.google.common.collect.Sets;
 
 /**
  * Defines a network.
@@ -40,9 +41,11 @@ public class Network {
         *
         * @param name
         *              The name of the network
+        * @throws NullPointerException
+        *              if {@code name} is {@code null}
         */
-       private Network(String name) {
-               this.name = name;
+       private Network(String name) throws NullPointerException {
+               this.name = checkNotNull(name, "name must not be null");
        }
 
        //
@@ -85,10 +88,7 @@ public class Network {
                        return false;
                }
                Network network = (Network) object;
-               if (!Objects.equal(name(), network.name())) {
-                       return false;
-               }
-               return true;
+               return name().equals(network.name());
        }
 
        @Override
@@ -214,6 +214,20 @@ public class Network {
                }
 
                /**
+                * Adds the given port numbers to the list of unencrypted port numbers.
+                *
+                * @param ports
+                *              The port numbers to add
+                * @return This server builder
+                */
+               public ServerBuilder ports(int... ports) {
+                       for (int port : ports) {
+                               unencryptedPorts.add(port);
+                       }
+                       return this;
+               }
+
+               /**
                 * Adds the given port number to the list of encrypted port numbers.
                 *
                 * @param sslPort
@@ -226,6 +240,20 @@ public class Network {
                }
 
                /**
+                * Adds the given port numbers to the list of encrypted port numbers.
+                *
+                * @param sslPorts
+                *              The port numbers to add
+                * @return This server builder
+                */
+               public ServerBuilder sslPorts(int... sslPorts) {
+                       for (int sslPort : sslPorts) {
+                               encryptedPorts.add(sslPort);
+                       }
+                       return this;
+               }
+
+               /**
                 * Builds the server, adds it to the parent network builder and returns the
                 * network builder.
                 *