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.collect.Sets;
/**
* Defines a 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");
}
//
//
@Override
+ public boolean equals(Object object) {
+ if (!(object instanceof Network)) {
+ return false;
+ }
+ Network network = (Network) object;
+ return name().equals(network.name());
+ }
+
+ @Override
+ public int hashCode() {
+ return name().hashCode();
+ }
+
+ @Override
public String toString() {
return String.format("%s(%d servers)", name(), servers().size());
}
}
/**
+ * 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
}
/**
+ * 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.
*