2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2024 Nordix Foundation.
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.drools.protocol.configuration;
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
28 import lombok.EqualsAndHashCode;
29 import lombok.NoArgsConstructor;
30 import lombok.ToString;
31 import org.onap.policy.common.gson.annotation.GsonJsonAnyGetter;
32 import org.onap.policy.common.gson.annotation.GsonJsonAnySetter;
33 import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
34 import org.onap.policy.common.gson.annotation.GsonJsonProperty;
38 * ENGINE-CONFIGURATION.
43 public class PdpdConfiguration {
45 /** Controller Entity ID. */
46 public static final String CONFIG_ENTITY_CONTROLLER = "controller";
48 protected static final Object NOT_FOUND_VALUE = new Object();
50 /** Unique Transaction ID. This is an UUID. (Required) */
51 @GsonJsonProperty("requestID")
52 private String requestId;
53 /* Set of entities on which configuration can be performed: controller (Required) */
54 @GsonJsonProperty("entity")
55 private String entity;
56 /* Controller Information, only applicable when the entity is set to controller */
57 @GsonJsonProperty("controllers")
58 private List<ControllerConfiguration> controllers = new ArrayList<>();
61 private final Map<String, Object> additionalProperties = new HashMap<>();
66 * @param requestId request id
67 * @param entity entity
68 * @param controllers controllers
70 public PdpdConfiguration(
71 String requestId, String entity, List<ControllerConfiguration> controllers) {
72 this.requestId = requestId;
74 this.controllers = controllers;
78 * Unique Transaction ID. This is an UUID. (Required)
80 * @return The requestID
82 @GsonJsonProperty("requestID")
83 public String getRequestId() {
88 * Unique Transaction ID. This is an UUID. (Required)
90 * @param requestId The requestID
92 @GsonJsonProperty("requestID")
93 public void setRequestId(String requestId) {
94 this.requestId = requestId;
97 public PdpdConfiguration withRequestId(String requestId) {
98 this.requestId = requestId;
103 * Set of entities on which configuration can be performed: controller (Required).
107 @GsonJsonProperty("entity")
108 public String getEntity() {
113 * Set of entities on which configuration can be performed: controller (Required).
115 * @param entity The entity
117 @GsonJsonProperty("entity")
118 public void setEntity(String entity) {
119 this.entity = entity;
122 public PdpdConfiguration withEntity(String entity) {
123 this.entity = entity;
128 * Controller Information, only applicable when the entity is set to controller.
130 * @return The controller
132 @GsonJsonProperty("controllers")
133 public List<ControllerConfiguration> getControllers() {
138 * Controller Information, only applicable when the entity is set to controller.
140 * @param controllers controllers
142 @GsonJsonProperty("controllers")
143 public void setControllers(List<ControllerConfiguration> controllers) {
144 this.controllers = controllers;
147 public PdpdConfiguration withController(List<ControllerConfiguration> controllers) {
148 this.controllers = controllers;
153 public Map<String, Object> getAdditionalProperties() {
154 return this.additionalProperties;
158 public void setAdditionalProperty(String name, Object value) {
159 this.additionalProperties.put(name, value);
162 public PdpdConfiguration withAdditionalProperty(String name, Object value) {
163 this.additionalProperties.put(name, value);
167 protected boolean declaredProperty(String name, Object value) {
170 callSetRequestId(value);
173 callSetEntity(value);
176 callSetControllers(value);
183 protected Object declaredPropertyOrNotFound(String name, Object notFoundValue) {
186 return getRequestId();
190 return getControllers();
192 return notFoundValue;
202 @SuppressWarnings({"unchecked"})
203 public <T> T get(String name) {
204 Object value = declaredPropertyOrNotFound(name, PdpdConfiguration.NOT_FOUND_VALUE);
205 if (PdpdConfiguration.NOT_FOUND_VALUE != value) {
208 return (T) getAdditionalProperties().get(name);
218 public void set(String name, Object value) {
219 if (!declaredProperty(name, value)) {
220 getAdditionalProperties().put(name, value);
225 * With - sets and returns the object.
227 public PdpdConfiguration with(String name, Object value) {
228 if (!declaredProperty(name, value)) {
229 getAdditionalProperties().put(name, value);
235 * Call set request id.
239 public void callSetRequestId(Object value) {
240 if (value instanceof String) {
241 setRequestId((String) value);
243 throw new IllegalArgumentException(
244 "property \"requestID\" is of type \"java.lang.String\", but got "
245 + value.getClass().toString());
254 public void callSetEntity(Object value) {
255 if (value instanceof String) {
256 setEntity((String) value);
258 throw new IllegalArgumentException(
259 "property \"entity\" is of type \"java.lang.String\", but got "
260 + value.getClass().toString());
265 * Call set controllers.
269 @SuppressWarnings("unchecked")
270 public void callSetControllers(Object value) {
271 if (value instanceof List) {
272 setControllers((List<ControllerConfiguration>) value);
274 throw new IllegalArgumentException(
275 "property \"controllers\" is of type "
276 + "\"java.util.List<org.onap.policy.drools.protocol.configuration.Controller>\", "