2020-02-06 22:17:14 +01:00
|
|
|
package envoy.client.data;
|
2019-10-30 06:26:50 +01:00
|
|
|
|
2020-07-09 09:13:26 +02:00
|
|
|
import static java.util.function.Function.identity;
|
|
|
|
|
2020-03-05 14:27:40 +01:00
|
|
|
import envoy.data.Config;
|
2019-12-13 08:50:15 +01:00
|
|
|
|
2019-10-30 06:26:50 +01:00
|
|
|
/**
|
2020-03-05 14:27:40 +01:00
|
|
|
* Implements a configuration specific to the Envoy Client with default values
|
2020-06-26 23:36:14 +02:00
|
|
|
* and convenience methods.
|
|
|
|
* <p>
|
2019-10-30 06:26:50 +01:00
|
|
|
* Project: <strong>envoy-client</strong><br>
|
2020-03-05 14:27:40 +01:00
|
|
|
* File: <strong>ClientConfig.java</strong><br>
|
|
|
|
* Created: <strong>01.03.2020</strong><br>
|
2019-12-20 20:25:54 +01:00
|
|
|
*
|
2019-10-30 06:26:50 +01:00
|
|
|
* @author Kai S. K. Engelbart
|
2020-03-23 21:52:33 +01:00
|
|
|
* @since Envoy Client v0.1-beta
|
2019-10-30 06:26:50 +01:00
|
|
|
*/
|
2020-08-22 13:37:07 +02:00
|
|
|
public final class ClientConfig extends Config {
|
2019-10-30 06:26:50 +01:00
|
|
|
|
2020-03-05 14:27:40 +01:00
|
|
|
private static ClientConfig config;
|
2019-11-09 14:23:26 +01:00
|
|
|
|
2020-03-05 14:27:40 +01:00
|
|
|
/**
|
|
|
|
* @return the singleton instance of the client config
|
2020-03-23 21:52:33 +01:00
|
|
|
* @since Envoy Client v0.1-beta
|
2020-03-05 14:27:40 +01:00
|
|
|
*/
|
|
|
|
public static ClientConfig getInstance() {
|
|
|
|
if (config == null) config = new ClientConfig();
|
|
|
|
return config;
|
|
|
|
}
|
2019-11-09 14:23:26 +01:00
|
|
|
|
2020-03-05 14:27:40 +01:00
|
|
|
private ClientConfig() {
|
2020-08-22 13:15:42 +02:00
|
|
|
super(".envoy");
|
2020-08-23 13:39:31 +02:00
|
|
|
put("server", "s", identity());
|
|
|
|
put("port", "p", Integer::parseInt);
|
2020-09-22 16:37:43 +02:00
|
|
|
put("localDBSaveInterval", "db-si", Integer::parseInt);
|
2019-12-21 11:35:01 +01:00
|
|
|
}
|
2019-11-09 14:23:26 +01:00
|
|
|
|
2019-10-30 06:26:50 +01:00
|
|
|
/**
|
2019-10-30 17:01:55 +01:00
|
|
|
* @return the host name of the Envoy server
|
2020-03-23 21:52:33 +01:00
|
|
|
* @since Envoy Client v0.1-alpha
|
2019-10-30 06:26:50 +01:00
|
|
|
*/
|
2019-12-21 11:35:01 +01:00
|
|
|
public String getServer() { return (String) items.get("server").get(); }
|
2019-10-30 06:26:50 +01:00
|
|
|
|
|
|
|
/**
|
2019-10-30 17:01:55 +01:00
|
|
|
* @return the port at which the Envoy server is located on the host
|
2020-03-23 21:52:33 +01:00
|
|
|
* @since Envoy Client v0.1-alpha
|
2019-10-30 06:26:50 +01:00
|
|
|
*/
|
2020-02-01 10:20:06 +01:00
|
|
|
public Integer getPort() { return (Integer) items.get("port").get(); }
|
2019-10-30 06:26:50 +01:00
|
|
|
|
2020-09-22 16:37:43 +02:00
|
|
|
/**
|
|
|
|
* @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(); }
|
2020-03-05 14:27:40 +01:00
|
|
|
}
|