From 71ef318e22d957e3e6187af3ad22777635505db9 Mon Sep 17 00:00:00 2001 From: Hannes Braun Date: Mon, 21 Aug 2023 15:24:41 +0200 Subject: [PATCH] Use a record for SimsparkAgentProxyServerParameter --- .../java/magma/tools/proxy/MagmaProxy.java | 2 +- .../proxy/impl/SimsparkAgentProxyServer.java | 55 ++----------------- 2 files changed, 7 insertions(+), 50 deletions(-) diff --git a/src/main/java/magma/tools/proxy/MagmaProxy.java b/src/main/java/magma/tools/proxy/MagmaProxy.java index 6cf592a..787db01 100644 --- a/src/main/java/magma/tools/proxy/MagmaProxy.java +++ b/src/main/java/magma/tools/proxy/MagmaProxy.java @@ -69,7 +69,7 @@ public static void main(String[] args) { SimsparkAgentProxyServerParameter parameterObject = parseParameters(args); SimsparkAgentProxyServer proxy = new SimsparkAgentProxyServer(parameterObject); - new MagmaProxy(proxy).run(parameterObject.isDaemon()); + new MagmaProxy(proxy).run(parameterObject.daemon()); } /** diff --git a/src/main/java/magma/tools/proxy/impl/SimsparkAgentProxyServer.java b/src/main/java/magma/tools/proxy/impl/SimsparkAgentProxyServer.java index 3f5e109..87f1da4 100644 --- a/src/main/java/magma/tools/proxy/impl/SimsparkAgentProxyServer.java +++ b/src/main/java/magma/tools/proxy/impl/SimsparkAgentProxyServer.java @@ -56,10 +56,10 @@ public class SimsparkAgentProxyServer extends Thread public SimsparkAgentProxyServer(SimsparkAgentProxyServerParameter parameterObject) { - this.proxyPort = parameterObject.getProxyPort(); - this.ssHost = parameterObject.getSsHost(); - this.ssPort = parameterObject.getSsPort(); - this.showMessages = parameterObject.isShowMessages(); + this.proxyPort = parameterObject.proxyPort(); + this.ssHost = parameterObject.ssHost(); + this.ssPort = parameterObject.ssPort(); + this.showMessages = parameterObject.showMessages(); agentProxies = new ArrayList<>(); } @@ -138,51 +138,8 @@ public ArrayList getAgentProxies() return agentProxies; } - public static class SimsparkAgentProxyServerParameter + public record SimsparkAgentProxyServerParameter( + int proxyPort, String ssHost, int ssPort, boolean showMessages, boolean daemon) { - private final int proxyPort; - - private final String ssHost; - - private final int ssPort; - - private final boolean showMessages; - - private final boolean daemon; - - public SimsparkAgentProxyServerParameter( - int proxyPort, String ssHost, int ssPort, boolean showMessages, boolean daemon) - { - this.proxyPort = proxyPort; - this.ssHost = ssHost; - this.ssPort = ssPort; - this.showMessages = showMessages; - this.daemon = daemon; - } - - public int getProxyPort() - { - return proxyPort; - } - - public String getSsHost() - { - return ssHost; - } - - public int getSsPort() - { - return ssPort; - } - - public boolean isShowMessages() - { - return showMessages; - } - - public boolean isDaemon() - { - return daemon; - } } }