X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fxdcc%2Fdata%2FNetwork.java;h=d78e71c882ae09b26ff94de18f18948dbb3567ad;hb=44825f1cf5ddb021cbf9b8416e8649e768905e77;hp=8fac0ea9c5bf3341320e2d009f73122899e88c3e;hpb=2986a1ee6f2ba3cfcd1d40ce117bfe6be5ff02dc;p=xudocci.git diff --git a/src/main/java/net/pterodactylus/xdcc/data/Network.java b/src/main/java/net/pterodactylus/xdcc/data/Network.java index 8fac0ea..d78e71c 100644 --- a/src/main/java/net/pterodactylus/xdcc/data/Network.java +++ b/src/main/java/net/pterodactylus/xdcc/data/Network.java @@ -17,10 +17,11 @@ 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. *