2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.models.simulators;
24 import java.util.LinkedList;
25 import java.util.List;
27 import org.onap.policy.common.endpoints.parameters.TopicParameters;
28 import org.onap.policy.common.parameters.BeanValidationResult;
29 import org.onap.policy.common.parameters.BeanValidator;
30 import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterGroup;
33 * Simulator parameters.
36 public class SimulatorParameters {
39 * Note: this is only used to capture the provider's parameters; the rest server
40 * parameters that it contains are ignored. Instead, the parameters for the rest
41 * server are contained within the {@link #restServers} entry having the same name as
42 * the provider parameters.
44 private DmaapSimParameterGroup dmaapProvider;
46 private CdsServerParameters grpcServer;
49 * Parameters for the REST server simulators that are to be started.
51 private List<ClassRestServerParameters> restServers = new LinkedList<>();
54 * Topic sinks that are used by {@link #topicServers}.
56 private List<TopicParameters> topicSinks = new LinkedList<>();
59 * Topic sources that are used by {@link #topicServers}.
61 private List<TopicParameters> topicSources = new LinkedList<>();
64 * Parameters for the TOPIC server simulators that are to be started.
66 private List<TopicServerParameters> topicServers = new LinkedList<>();
70 * Validates the parameters.
72 * @param containerName name of the parameter container
73 * @return the validation result
75 public BeanValidationResult validate(String containerName) {
76 BeanValidationResult result = new BeanValidator().validateTop(containerName, this);
78 if (dmaapProvider != null) {
79 result.addResult(dmaapProvider.validate());
82 if (grpcServer != null) {
83 result.addResult(grpcServer.validate());
86 result.validateList("restServers", restServers, params -> params.validate("restServers"));
87 result.validateList("topicServers", topicServers, params -> params.validate("topicServers"));