2  * ============LICENSE_START=======================================================
 
   3  *  Copyright (C) 2018 Intel. All rights reserved.
 
   4  * ================================================================================
 
   5  * Licensed under the Apache License, Version 2.0 (the "License");
 
   6  * you may not use this file except in compliance with the License.
 
   7  * You may obtain a copy of the License at
 
   9  *      http://www.apache.org/licenses/LICENSE-2.0
 
  11  * Unless required by applicable law or agreed to in writing, software
 
  12  * distributed under the License is distributed on an "AS IS" BASIS,
 
  13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  14  * See the License for the specific language governing permissions and
 
  15  * limitations under the License.
 
  17  * SPDX-License-Identifier: Apache-2.0
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.policy.distribution.reception.decoding.pdpx;
 
  23 import org.onap.policy.common.parameters.GroupValidationResult;
 
  24 import org.onap.policy.common.parameters.ValidationStatus;
 
  25 import org.onap.policy.common.utils.validation.ParameterValidationUtils;
 
  26 import org.onap.policy.distribution.reception.handling.sdc.SdcReceptionHandlerConfigurationParameterGroup;
 
  27 import org.onap.policy.distribution.reception.parameters.PolicyDecoderConfigurationParameterGroup;
 
  30  * This class handles reading, parsing and validating of the paramaters for the
 
  31  * {@link PolicyDecoderCsarPdpx}.
 
  33 public class PolicyDecoderCsarPdpxConfigurationParameterGroup extends PolicyDecoderConfigurationParameterGroup {
 
  35     private String policyNamePrefix;
 
  36     private String onapName;
 
  37     private String version;
 
  38     private String priority;
 
  39     private String riskType;
 
  40     private String riskLevel;
 
  43      * The constructor for instantiating {@link SdcReceptionHandlerConfigurationParameterGroup}
 
  46      * @param builder the SDC configuration builder
 
  48     public PolicyDecoderCsarPdpxConfigurationParameterGroup(
 
  49             final PolicyDecoderCsarPdpxConfigurationParameterBuilder builder) {
 
  50         policyNamePrefix = builder.getPolicyNamePrefix();
 
  51         onapName = builder.getOnapName();
 
  52         version = builder.getVersion();
 
  53         priority = builder.getPriority();
 
  54         riskType = builder.getRiskType();
 
  55         riskLevel = builder.getRiskLevel();
 
  58     public String getPolicyNamePrefix() {
 
  59         return policyNamePrefix;
 
  62     public String getOnapName() {
 
  66     public String getVersion() {
 
  70     public String getPriority() {
 
  74     public String getRiskType() {
 
  78     public String getRiskLevel() {
 
  86     public GroupValidationResult validate() {
 
  87         final GroupValidationResult validationResult = new GroupValidationResult(this);
 
  88         validateStringElement(validationResult, policyNamePrefix, "policyNamePrefix");
 
  89         validateStringElement(validationResult, onapName, "onapName");
 
  90         validateStringElement(validationResult, version, "version");
 
  91         validateStringElement(validationResult, priority, "priority");
 
  92         validateStringElement(validationResult, riskType, "riskType");
 
  93         validateStringElement(validationResult, riskLevel, "riskLevel");
 
  94         return validationResult;
 
  98      * Validate the string element.
 
 100      * @param validationResult the result object
 
 101      * @param element the element to validate
 
 102      * @param elementName the element name for error message
 
 104     private void validateStringElement(final GroupValidationResult validationResult, final String element,
 
 105             final String elementName) {
 
 106         if (!ParameterValidationUtils.validateStringParameter(element)) {
 
 107             validationResult.setResult(elementName, ValidationStatus.INVALID,
 
 108                     elementName + " must be a non-blank string");