From 5e95cee500a33beaf8a70c8cfc44130c012af1bb Mon Sep 17 00:00:00 2001 From: Maximilien LEDOUX Date: Sat, 5 Mar 2022 16:59:40 +0100 Subject: [PATCH] =?UTF-8?q?Syst=C3=A8me=20de=20synchronisation=20de=20l'in?= =?UTF-8?q?formation=20entre=20FileFrontEnd<>StorBackEnd=20->=20impl=C3=A9?= =?UTF-8?q?mentation=20de=20AppConfig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lightcontainer/storage/AppConfig.java | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 app/src/main/java/lightcontainer/storage/AppConfig.java diff --git a/app/src/main/java/lightcontainer/storage/AppConfig.java b/app/src/main/java/lightcontainer/storage/AppConfig.java new file mode 100644 index 0000000..7f767b8 --- /dev/null +++ b/app/src/main/java/lightcontainer/storage/AppConfig.java @@ -0,0 +1,88 @@ +package lightcontainer.storage; + +/** + * AppConfig represents all network related information needed for the program to work. + * + * @author Maximilien LEDOUX + * @version 1.0 + * @since 1.0 + */ +public class AppConfig { + + private static AppConfig instance = null; + private int unicastPort; + private String multicastIp; + private int multicastPort; + private String networkInterface; + private boolean isTls; + + /** + * Constructs a new instance of AppConfig. + * Sets all data to default values. + */ + private AppConfig() { + this.unicastPort = -1; + this.multicastIp = "NONE"; + this.multicastPort = -1; + this.networkInterface = "NONE"; + this.isTls = false; + } + + /** + * @return An instance of this class. Always returns the same instance. + */ + public static AppConfig getInstance() { + if (instance == null) { + instance = new AppConfig(); + } + return instance; + } + + public int getUnicastPort() { + return unicastPort; + } + + public void setUnicastPort(int unicastPort) { + if (this.unicastPort == -1) { + this.unicastPort = unicastPort; + } + } + + public String getMulticastIp() { + return multicastIp; + } + + public void setMulticastIp(String multicastIp) { + if (this.multicastIp.equals("NONE")) { + this.multicastIp = multicastIp; + } + } + + public int getMulticastPort() { + return multicastPort; + } + + public void setMulticastPort(int multicastPort) { + if (this.multicastPort == -1) { + this.multicastPort = multicastPort; + } + } + + public String getNetworkInterface() { + return networkInterface; + } + + public void setNetworkInterface(String networkInterface) { + if (this.networkInterface.equals("NONE")) { + this.networkInterface = networkInterface; + } + } + + public boolean isTls() { + return isTls; + } + + public void setTls(boolean tls) { + this.isTls = tls; + } +}