From d8fe269327a1a51f2588a3573a4764613da16388 Mon Sep 17 00:00:00 2001 From: Trumeet Date: Tue, 26 Jul 2022 19:06:11 -0700 Subject: Move the mod to mod/ --- .../java/moe/ymc/acron/config/json/Config.java | 103 --------------------- 1 file changed, 103 deletions(-) delete mode 100644 src/main/java/moe/ymc/acron/config/json/Config.java (limited to 'src/main/java/moe/ymc/acron/config/json/Config.java') diff --git a/src/main/java/moe/ymc/acron/config/json/Config.java b/src/main/java/moe/ymc/acron/config/json/Config.java deleted file mode 100644 index e8c5a83..0000000 --- a/src/main/java/moe/ymc/acron/config/json/Config.java +++ /dev/null @@ -1,103 +0,0 @@ -package moe.ymc.acron.config.json; - -import com.google.gson.annotations.SerializedName; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.NotNull; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -class Config implements ConfigJsonObject { - private static final Logger LOGGER = LogManager.getLogger(); - - @SerializedName("listen") - private final String listen; - - @SerializedName("port") - private final Integer port; - - @SerializedName("native_transport") - private final boolean nativeTransport; - - @SerializedName("clients") - private final List clients; - - private Config(String listen, - Integer port, - boolean nativeTransport, - List clients) { - this.listen = listen; - this.port = port; - this.nativeTransport = nativeTransport; - this.clients = clients; - } - - @Override - public @NotNull moe.ymc.acron.config.Config create(boolean startup) throws ConfigDeserializationException { - final InetAddress address; - final int p; - final boolean nt; - if (!startup) { - address = moe.ymc.acron.config.Config.getGlobalConfig().address(); - p = moe.ymc.acron.config.Config.getGlobalConfig().port(); - nt = moe.ymc.acron.config.Config.getGlobalConfig().useNativeTransport(); - } else { - if (listen == null || listen.trim().equals("")) { - address = InetAddress.getLoopbackAddress(); - } else { - try { - address = InetAddress.getByName(listen); - } catch (UnknownHostException e) { - throw new ConfigDeserializationException("Cannot parse address: " + e.getMessage(), - true); - } - } - if (port == null) { - p = 25575; - } else { - if (port < 0 || port > 65535) { - throw new ConfigDeserializationException("The port is out of range.", true); - } - p = port; - } - nt = nativeTransport; - } - - - Map map; - try { - if (clients != null) { - map = clients.stream() - .collect(Collectors. - toMap(client -> client.create(startup).id(), - client -> client.create(startup))); - } else { - map = new HashMap<>(0); - } - } catch (IllegalStateException e) { - // Collision. - LOGGER.error("Duplicate clients with the same ID in the Acron configuration. All clients are ignored. " + - "Fix the configuration and reload.", e); - if (!startup) { - throw new ConfigDeserializationException("Duplicate clients with the same ID: " + e.getMessage()); - } - map = new HashMap<>(0); - } catch (ConfigDeserializationException e) { - LOGGER.error("Cannot parse the Acron configuration. All clients are ignored. " + - "Fix the configuration and reload.", e); - if (!startup) { - throw e; - } - map = new HashMap<>(0); - } - return new moe.ymc.acron.config.Config(address, - p, - nt, - map); - } -} -- cgit v1.2.3