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; + } +}