package envoy.client.data; import static java.util.function.Function.identity; import envoy.data.Config; /** * Implements a configuration specific to the Envoy Client with default values * and convenience methods. *
* Project: envoy-client
* File: ClientConfig.java
* Created: 01.03.2020
*
* @author Kai S. K. Engelbart
* @since Envoy Client v0.1-beta
*/
public final class ClientConfig extends Config {
private static ClientConfig config;
/**
* @return the singleton instance of the client config
* @since Envoy Client v0.1-beta
*/
public static ClientConfig getInstance() {
if (config == null) config = new ClientConfig();
return config;
}
private ClientConfig() {
super(".envoy");
put("server", "s", identity());
put("port", "p", Integer::parseInt);
put("localDBSaveInterval", "db-si", Integer::parseInt);
}
/**
* @return the host name of the Envoy server
* @since Envoy Client v0.1-alpha
*/
public String getServer() { return (String) items.get("server").get(); }
/**
* @return the port at which the Envoy server is located on the host
* @since Envoy Client v0.1-alpha
*/
public Integer getPort() { return (Integer) items.get("port").get(); }
/**
* @return the amount of minutes after which the local database should be saved
* @since Envoy Client v0.2-beta
*/
public Integer getLocalDBSaveInterval() { return (Integer) items.get("localDBSaveInterval").get(); }
}