diff options
author | Jim Hahn <jrh3@att.com> | 2021-05-03 17:00:16 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-05-03 17:00:16 +0000 |
commit | da708d64dc27f36ed5da733fca14ebfb4cc2832b (patch) | |
tree | 4af7d16af7c578a885fd9d6f48855299fcf6a5ad /models-provider/src/main/java | |
parent | eb830bfda2a18618032434aa7ebe3501bca2cca7 (diff) | |
parent | 4fdecb037bd2609a6b977adba6d2f263c977d9e1 (diff) |
Merge "Remove GroupValidationResult"
Diffstat (limited to 'models-provider/src/main/java')
-rw-r--r-- | models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderParameters.java | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderParameters.java b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderParameters.java index 19345553b..bcd14c82b 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderParameters.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderParameters.java @@ -23,10 +23,11 @@ package org.onap.policy.models.provider; import lombok.Data; -import org.onap.policy.common.parameters.GroupValidationResult; +import org.onap.policy.common.parameters.BeanValidationResult; +import org.onap.policy.common.parameters.BeanValidator; import org.onap.policy.common.parameters.ParameterGroup; -import org.onap.policy.common.parameters.ValidationStatus; -import org.onap.policy.common.utils.validation.ParameterValidationUtils; +import org.onap.policy.common.parameters.annotations.NotBlank; +import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl; // @formatter:off @@ -55,42 +56,25 @@ public class PolicyModelsProviderParameters implements ParameterGroup { private static final String DEFAULT_IMPLEMENTATION = DatabasePolicyModelsProviderImpl.class.getName(); private String name; + @NotNull @NotBlank private String implementation = DEFAULT_IMPLEMENTATION; private String databaseType; + @NotNull @NotBlank private String databaseDriver; + @NotNull @NotBlank private String databaseUrl; private String databaseUser; private String databasePassword; + @NotNull @NotBlank private String persistenceUnit; /** * Validate the model provider parameters. * */ - @Override - public GroupValidationResult validate() { - final GroupValidationResult validationResult = new GroupValidationResult(this); - - if (!ParameterValidationUtils.validateStringParameter(implementation)) { - validationResult.setResult("implementation", ValidationStatus.INVALID, - "a PolicyModelsProvider implementation must be specified"); - } - - if (!ParameterValidationUtils.validateStringParameter(databaseDriver)) { - validationResult.setResult("databaseUrl", ValidationStatus.INVALID, - "a driver must be specified for the JDBC connection to the database"); - } - if (!ParameterValidationUtils.validateStringParameter(databaseUrl)) { - validationResult.setResult("databaseUrl", ValidationStatus.INVALID, - "a URL must be specified for the JDBC connection to the database"); - } - - if (!ParameterValidationUtils.validateStringParameter(persistenceUnit)) { - validationResult.setResult("persistenceUnit", ValidationStatus.INVALID, - "a persistence unit must be specified for connecting to the database"); - } - - return validationResult; + @Override + public BeanValidationResult validate() { + return new BeanValidator().validateTop(getClass().getSimpleName(), this); } } |