2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2021 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.drools.protocol.configuration;
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
27 import lombok.EqualsAndHashCode;
28 import lombok.NoArgsConstructor;
29 import lombok.ToString;
30 import org.onap.policy.common.gson.annotation.GsonJsonAnyGetter;
31 import org.onap.policy.common.gson.annotation.GsonJsonAnySetter;
32 import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
33 import org.onap.policy.common.gson.annotation.GsonJsonProperty;
37 * ENGINE-CONFIGURATION.
42 public class PdpdConfiguration {
44 /** Controller Entity ID. */
45 public static final String CONFIG_ENTITY_CONTROLLER = "controller";
47 protected static final Object NOT_FOUND_VALUE = new Object();
49 /** Unique Transaction ID. This is an UUID. (Required) */
50 @GsonJsonProperty("requestID")
51 private String requestId;
52 /* Set of entities on which configuration can be performed: controller (Required) */
53 @GsonJsonProperty("entity")
54 private String entity;
55 /* Controller Information, only applicable when the entity is set to controller */
56 @GsonJsonProperty("controllers")
57 private List<ControllerConfiguration> controllers = new ArrayList<>();
59 @GsonJsonIgnore private Map<String, Object> additionalProperties = new HashMap<>();
64 * @param requestId request id
65 * @param entity entity
66 * @param controllers controllers
68 public PdpdConfiguration(
69 String requestId, String entity, List<ControllerConfiguration> controllers) {
70 this.requestId = requestId;
72 this.controllers = controllers;
76 * Unique Transaction ID. This is an UUID. (Required)
78 * @return The requestID
80 @GsonJsonProperty("requestID")
81 public String getRequestId() {
86 * Unique Transaction ID. This is an UUID. (Required)
88 * @param requestId The requestID
90 @GsonJsonProperty("requestID")
91 public void setRequestId(String requestId) {
92 this.requestId = requestId;
95 public PdpdConfiguration withRequestId(String requestId) {
96 this.requestId = requestId;
101 * Set of entities on which configuration can be performed: controller (Required).
105 @GsonJsonProperty("entity")
106 public String getEntity() {
111 * Set of entities on which configuration can be performed: controller (Required).
113 * @param entity The entity
115 @GsonJsonProperty("entity")
116 public void setEntity(String entity) {
117 this.entity = entity;
120 public PdpdConfiguration withEntity(String entity) {
121 this.entity = entity;
126 * Controller Information, only applicable when the entity is set to controller.
128 * @return The controller
130 @GsonJsonProperty("controllers")
131 public List<ControllerConfiguration> getControllers() {
136 * Controller Information, only applicable when the entity is set to controller.
138 * @param controllers controllers
140 @GsonJsonProperty("controllers")
141 public void setControllers(List<ControllerConfiguration> controllers) {
142 this.controllers = controllers;
145 public PdpdConfiguration withController(List<ControllerConfiguration> controllers) {
146 this.controllers = controllers;
151 public Map<String, Object> getAdditionalProperties() {
152 return this.additionalProperties;
156 public void setAdditionalProperty(String name, Object value) {
157 this.additionalProperties.put(name, value);
160 public PdpdConfiguration withAdditionalProperty(String name, Object value) {
161 this.additionalProperties.put(name, value);
165 protected boolean declaredProperty(String name, Object value) {
168 callSetRequestId(value);
171 callSetEntity(value);
174 callSetControllers(value);
181 protected Object declaredPropertyOrNotFound(String name, Object notFoundValue) {
184 return getRequestId();
188 return getControllers();
190 return notFoundValue;
200 @SuppressWarnings({"unchecked"})
201 public <T> T get(String name) {
202 Object value = declaredPropertyOrNotFound(name, PdpdConfiguration.NOT_FOUND_VALUE);
203 if (PdpdConfiguration.NOT_FOUND_VALUE != value) {
206 return (T) getAdditionalProperties().get(name);
216 public void set(String name, Object value) {
217 if (!declaredProperty(name, value)) {
218 getAdditionalProperties().put(name, value);
223 * With - sets and returns the object.
225 public PdpdConfiguration with(String name, Object value) {
226 if (!declaredProperty(name, value)) {
227 getAdditionalProperties().put(name, value);
233 * Call set request id.
237 public void callSetRequestId(Object value) {
238 if (value instanceof String) {
239 setRequestId((String) value);
241 throw new IllegalArgumentException(
242 "property \"requestID\" is of type \"java.lang.String\", but got "
243 + value.getClass().toString());
252 public void callSetEntity(Object value) {
253 if (value instanceof String) {
254 setEntity((String) value);
256 throw new IllegalArgumentException(
257 "property \"entity\" is of type \"java.lang.String\", but got "
258 + value.getClass().toString());
263 * Call set controllers.
267 @SuppressWarnings("unchecked")
268 public void callSetControllers(Object value) {
269 if (value instanceof List) {
270 setControllers((List<ControllerConfiguration>) value);
272 throw new IllegalArgumentException(
273 "property \"controllers\" is of type "
274 + "\"java.util.List<org.onap.policy.drools.protocol.configuration.Controller>\", "
276 + value.getClass().toString());