Système de synchronisation de l'information entre FileFrontEnd<>StorBackEnd -> implémentation de AppConfig

This commit is contained in:
Maximilien LEDOUX 2022-03-05 16:59:40 +01:00
parent 2f1f72b1fc
commit 5e95cee500

View File

@ -0,0 +1,88 @@
package lightcontainer.storage;
/**
* AppConfig represents all network related information needed for the program to work.
*
* @author Maximilien LEDOUX <m.ledoux@student.helmo.be>
* @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;
}
}