Skip to content

Instantly share code, notes, and snippets.

@dalexandrov
Last active February 23, 2021 13:48
Show Gist options
  • Save dalexandrov/835cba3c013c48cd59930e44a899c3e6 to your computer and use it in GitHub Desktop.
Save dalexandrov/835cba3c013c48cd59930e44a899c3e6 to your computer and use it in GitHub Desktop.
builder.java
public Builder config(Config config) {
config.get("authentication.username").asString().ifPresent(this::username);
config.get("authentication.password").asString().ifPresent(this::password);
config.get("authentication.enabled").asBoolean().ifPresent(this::authenticationEnabled);
config.get("uri").asString().ifPresent(this::uri);
config.get("encrypted").asBoolean().ifPresent(this::encrypted);
//pool
config.get("pool.metricsEnabled").asBoolean().ifPresent(this::metricsEnabled);
config.get("pool.logLeakedSessions").asBoolean().ifPresent(this::logLeakedSessions);
config.get("pool.maxConnectionPoolSize").asInt().ifPresent(this::maxConnectionPoolSize);
config.get("pool.idleTimeBeforeConnectionTest").as(Duration.class).ifPresent(this::idleTimeBeforeConnectionTest);
config.get("pool.maxConnectionLifetime").as(Duration.class).ifPresent(this::maxConnectionLifetime);
config.get("pool.connectionAcquisitionTimeout").as(Duration.class).ifPresent(this::connectionAcquisitionTimeout);
//trust config.get("trustsettings.trustStrategy").asString().map(TrustStrategy::valueOf).ifPresent(this::trustStrategy);
config.get("trustsettings.certificate").as(Path.class).ifPresent(this::certificate);
config.get("trustsettings.hostnameVerificationEnabled").asBoolean().ifPresent(this::hostnameVerificationEnabled);
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment