Merge "Enhance gRPC Simulator:"
[policy/models.git] / models-sim / policy-models-simulators / src / main / java / org / onap / policy / models / simulators / SimulatorParameters.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
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
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  */
21
22 package org.onap.policy.models.simulators;
23
24 import java.util.LinkedList;
25 import java.util.List;
26 import lombok.Getter;
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.common.parameters.annotations.NotNull;
31 import org.onap.policy.models.sim.dmaap.parameters.DmaapSimParameterGroup;
32
33 /**
34  * Simulator parameters.
35  */
36 @Getter
37 @NotNull
38 public class SimulatorParameters {
39
40     /**
41      * Note: this is only used to capture the provider's parameters; the rest server
42      * parameters that it contains are ignored. Instead, the parameters for the rest
43      * server are contained within the {@link #restServers} entry having the same name as
44      * the provider parameters.
45      */
46     private DmaapSimParameterGroup dmaapProvider;
47
48     private CdsServerParameters grpcServer;
49
50     /**
51      * Parameters for the REST server simulators that are to be started.
52      */
53     private List<ClassRestServerParameters> restServers = new LinkedList<>();
54
55     /**
56      * Topic sinks that are used by {@link #topicServers}.
57      */
58     private List<TopicParameters> topicSinks = new LinkedList<>();
59
60     /**
61      * Topic sources that are used by {@link #topicServers}.
62      */
63     private List<TopicParameters> topicSources = new LinkedList<>();
64
65     /**
66      * Parameters for the TOPIC server simulators that are to be started.
67      */
68     private List<TopicServerParameters> topicServers = new LinkedList<>();
69
70
71     /**
72      * Validates the parameters.
73      *
74      * @param containerName name of the parameter container
75      * @return the validation result
76      */
77     public BeanValidationResult validate(String containerName) {
78         BeanValidationResult result = new BeanValidator().validateTop(containerName, this);
79
80         result.validateList("restServers", restServers, params -> params.validate("restServers"));
81         result.validateList("topicServers", topicServers, params -> params.validate("topicServers"));
82
83         return result;
84     }
85 }