47 lines
1.1 KiB
Java
47 lines
1.1 KiB
Java
package envoy.client;
|
|
|
|
import java.util.Properties;
|
|
|
|
/**
|
|
* Project: <strong>envoy-client</strong><br>
|
|
* File: <strong>Config.java</strong><br>
|
|
* Created: <strong>12 Oct 2019</strong><br>
|
|
*
|
|
* @author Kai S. K. Engelbart
|
|
* @since Envoy 0.1
|
|
*/
|
|
public class Config {
|
|
|
|
private String server;
|
|
private int port;
|
|
|
|
public void load(Properties properties) {
|
|
if (properties.containsKey("server")) server = properties.getProperty("server");
|
|
if (properties.containsKey("port")) port = Integer.parseInt(properties.getProperty("port"));
|
|
}
|
|
|
|
public void load(String[] args) {
|
|
for (int i = 0; i < args.length; i++)
|
|
switch (args[i]) {
|
|
case "--server":
|
|
case "-s":
|
|
server = args[++i];
|
|
break;
|
|
case "--port":
|
|
case "-p":
|
|
port = Integer.parseInt(args[++i]);
|
|
break;
|
|
}
|
|
}
|
|
|
|
public boolean isInitialized() { return server != null && !server.isEmpty() && port > 0; }
|
|
|
|
public String getServer() { return server; }
|
|
|
|
public void setServer(String server) { this.server = server; }
|
|
|
|
public int getPort() { return port; }
|
|
|
|
public void setPort(int port) { this.port = port; }
|
|
}
|