diff options
author | Jim Hahn <jrh3@att.com> | 2021-04-26 18:16:36 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-04-29 11:35:02 -0400 |
commit | 4fdecb037bd2609a6b977adba6d2f263c977d9e1 (patch) | |
tree | cac0861d73c073e33e2b677fc6c9356e3dcf3574 /models-provider/src/main/java/org/onap | |
parent | 6e589fc31f69482d2cf5bf57c733094394439b0f (diff) |
Remove GroupValidationResult
Removed GroupValidationResult, replacing it with BeanValidationResult.
Modified the ParameterGroup subclasses to use BeanValidator, adding
annotations where needed to trigger the validations that had been
automatically performed by GroupValidationResult.
Issue-ID: POLICY-2059
Change-Id: I245e4a647fcbb718faa63a7543f9f81c85da958c
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-provider/src/main/java/org/onap')
-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); } } |