2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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 com.fasterxml.jackson.annotation.JsonAnyGetter;
28 import com.fasterxml.jackson.annotation.JsonAnySetter;
29 import com.fasterxml.jackson.annotation.JsonIgnore;
30 import com.fasterxml.jackson.annotation.JsonInclude;
31 import com.fasterxml.jackson.annotation.JsonProperty;
32 import org.apache.commons.lang3.builder.EqualsBuilder;
33 import org.apache.commons.lang3.builder.HashCodeBuilder;
34 import org.apache.commons.lang3.builder.ToStringBuilder;
38 * ENGINE-CONFIGURATION
43 @JsonInclude(JsonInclude.Include.NON_NULL)
44 public class PdpdConfiguration {
47 * Controller Entity ID
49 public static final String CONFIG_ENTITY_CONTROLLER = "controller";
52 * Unique Transaction ID. This is an UUID.
56 @JsonProperty("requestID")
57 private String requestID;
59 * Set of entities on which configuration can be performed: controller
63 @JsonProperty("entity")
64 private String entity;
66 * Controller Information, only applicable when the entity is set to controller
69 @JsonProperty("controllers")
70 private List<ControllerConfiguration> controllers = new ArrayList<>();
72 private Map<String, Object> additionalProperties = new HashMap<>();
73 protected static final Object NOT_FOUND_VALUE = new Object();
76 * No args constructor for use in serialization
79 public PdpdConfiguration() {
89 public PdpdConfiguration(String requestID, String entity, List<ControllerConfiguration> controllers) {
90 this.requestID = requestID;
92 this.controllers = controllers;
96 * Unique Transaction ID. This is an UUID.
102 @JsonProperty("requestID")
103 public String getRequestID() {
108 * Unique Transaction ID. This is an UUID.
114 @JsonProperty("requestID")
115 public void setRequestID(String requestID) {
116 this.requestID = requestID;
119 public PdpdConfiguration withRequestID(String requestID) {
120 this.requestID = requestID;
125 * Set of entities on which configuration can be performed: controller
131 @JsonProperty("entity")
132 public String getEntity() {
137 * Set of entities on which configuration can be performed: controller
143 @JsonProperty("entity")
144 public void setEntity(String entity) {
145 this.entity = entity;
148 public PdpdConfiguration withEntity(String entity) {
149 this.entity = entity;
154 * Controller Information, only applicable when the entity is set to controller
159 @JsonProperty("controller")
160 public List<ControllerConfiguration> getControllers() {
165 * Controller Information, only applicable when the entity is set to controller
170 @JsonProperty("controller")
171 public void setControllers(List<ControllerConfiguration> controllers) {
172 this.controllers = controllers;
175 public PdpdConfiguration withController(List<ControllerConfiguration> controllers) {
176 this.controllers = controllers;
181 public String toString() {
182 return ToStringBuilder.reflectionToString(this);
186 public Map<String, Object> getAdditionalProperties() {
187 return this.additionalProperties;
191 public void setAdditionalProperty(String name, Object value) {
192 this.additionalProperties.put(name, value);
195 public PdpdConfiguration withAdditionalProperty(String name, Object value) {
196 this.additionalProperties.put(name, value);
200 protected boolean declaredProperty(String name, Object value) {
203 callSetRequestId(value);
206 callSetEntity(value);
209 callSetControllers(value);
216 protected Object declaredPropertyOrNotFound(String name, Object notFoundValue) {
219 return getRequestID();
223 return getControllers();
225 return notFoundValue;
232 public<T >T get(String name) {
233 Object value = declaredPropertyOrNotFound(name, PdpdConfiguration.NOT_FOUND_VALUE);
234 if (PdpdConfiguration.NOT_FOUND_VALUE!= value) {
237 return (T) getAdditionalProperties().get(name);
241 public void set(String name, Object value) {
242 if (!declaredProperty(name, value)) {
243 getAdditionalProperties().put(name, value);
247 public PdpdConfiguration with(String name, Object value) {
248 if (!declaredProperty(name, value)) {
249 getAdditionalProperties().put(name, value);
255 public int hashCode() {
256 return new HashCodeBuilder().append(requestID).append(entity).append(controllers).append(additionalProperties).toHashCode();
260 public boolean equals(Object other) {
264 if (!(other instanceof PdpdConfiguration)) {
267 PdpdConfiguration rhs = (PdpdConfiguration) other;
268 return new EqualsBuilder().append(requestID, rhs.requestID).append(entity, rhs.entity).append(controllers, rhs.controllers).append(additionalProperties, rhs.additionalProperties).isEquals();
271 public void callSetRequestId(Object value) {
272 if (value instanceof String) {
273 setRequestID((String) value);
275 throw new IllegalArgumentException("property \"requestID\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
279 public void callSetEntity(Object value) {
280 if (value instanceof String) {
281 setEntity((String) value);
283 throw new IllegalArgumentException("property \"entity\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
287 @SuppressWarnings("unchecked")
288 public void callSetControllers(Object value) {
289 if (value instanceof List) {
290 setControllers((List<ControllerConfiguration> ) value);
292 throw new IllegalArgumentException("property \"controllers\" is of type \"java.util.List<org.onap.policy.drools.protocol.configuration.Controller>\", but got "+ value.getClass().toString());