Skip to content

Commit

Permalink
Added missing methods and Javadoc comment.
Browse files Browse the repository at this point in the history
Signed-off-by: Juergen Fickel <juergen.fickel@bosch-si.com>
  • Loading branch information
Juergen Fickel committed Mar 7, 2019
1 parent 8ad0b56 commit 4991ab6
Showing 1 changed file with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package org.eclipse.ditto.services.policies.starter.config;

import java.io.Serializable;
import java.util.Objects;

import javax.annotation.concurrent.Immutable;

Expand All @@ -25,14 +26,18 @@
import org.eclipse.ditto.services.utils.health.config.HealthCheckConfig;
import org.eclipse.ditto.services.utils.persistence.mongo.config.MongoDbConfig;

import com.typesafe.config.Config;

/**
* TODO Javadoc
* This class implements the config of the Ditto Policies service.
*/
@Immutable
public final class DittoPoliciesConfig implements PoliciesConfig, Serializable {

private static final String CONFIG_PATH = "policies";

private static final long serialVersionUID = -9097093192571860894L;

private final DittoServiceWithMongoDbConfig dittoServiceConfig;
private final HealthCheckConfig healthCheckConfig;
private final PolicyConfig policyConfig;
Expand All @@ -48,14 +53,14 @@ private DittoPoliciesConfig(final DittoServiceWithMongoDbConfig dittoServiceConf
}

/**
* Returns an instance of {@code DittoPoliciesConfig} based on the settings of the specified Config.
* Returns an instance of the policies config based on the settings of the specified Config.
*
* @param dittoScopedConfig is supposed to provide the settings of the Policies service config at
* {@value #CONFIG_PATH}.
* @return the instance.
* @throws org.eclipse.ditto.services.utils.config.DittoConfigError if {@code config} is invalid.
*/
public static DittoPoliciesConfig of(final ScopedConfig dittoScopedConfig) {
public static DittoPoliciesConfig of(final Config dittoScopedConfig) {
return new DittoPoliciesConfig(DittoServiceWithMongoDbConfig.of(dittoScopedConfig, CONFIG_PATH),
DefaultScopedConfig.newInstance(dittoScopedConfig, CONFIG_PATH));
}
Expand Down Expand Up @@ -100,4 +105,34 @@ public TagsConfig getTagsConfig() {
return tagsConfig;
}

@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final DittoPoliciesConfig that = (DittoPoliciesConfig) o;
return Objects.equals(dittoServiceConfig, that.dittoServiceConfig) &&
Objects.equals(healthCheckConfig, that.healthCheckConfig) &&
Objects.equals(policyConfig, that.policyConfig) &&
Objects.equals(tagsConfig, that.tagsConfig);
}

@Override
public int hashCode() {
return Objects.hash(dittoServiceConfig, healthCheckConfig, policyConfig, tagsConfig);
}

@Override
public String toString() {
return getClass().getSimpleName() + " [" +
"dittoServiceConfig=" + dittoServiceConfig +
", healthCheckConfig=" + healthCheckConfig +
", policyConfig=" + policyConfig +
", tagsConfig=" + tagsConfig +
"]";
}

}

0 comments on commit 4991ab6

Please sign in to comment.