2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.controlloop.actorserviceprovider.parameters;
24 import lombok.Builder;
26 import org.onap.policy.common.parameters.BeanValidationResult;
27 import org.onap.policy.common.parameters.BeanValidator;
28 import org.onap.policy.common.parameters.ValidationResult;
29 import org.onap.policy.common.parameters.annotations.NotBlank;
30 import org.onap.policy.common.parameters.annotations.NotNull;
33 * Parameters used by Actors whose Operators use a pair of Topics, one to publish requests
34 * and the other to receive responses.
40 public class TopicPairActorParams {
43 * This contains the default parameters that are used when an operation doesn't
44 * specify them. Note: each operation to be used must still have an entry in
45 * {@link #operation}, even if it's empty. Otherwise, the given operation will not be
48 private TopicPairParams defaults;
51 * Maps an operation name to its individual parameters.
53 private Map<String, Map<String, Object>> operation;
57 * Validates the parameters.
59 * @param name name of the object containing these parameters
61 * @throws IllegalArgumentException if the parameters are invalid
63 public TopicPairActorParams doValidation(String name) {
64 ValidationResult result = validate(name);
65 if (!result.isValid()) {
66 throw new ParameterValidationRuntimeException("invalid parameters", result);
73 * Validates the parameters.
75 * @param resultName name of the result
77 * @return the validation result
79 public ValidationResult validate(String resultName) {
80 BeanValidationResult result = new BeanValidator().validateTop(resultName, this);
82 if (defaults != null) {
83 result.addResult(defaults.validate("defaults"));
87 result.validateMap("operation", operation,
88 (result2, entry) -> result2.validateNotNull(entry.getKey(), entry.getValue()));