2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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<ControllerConfiguration>();
72 private Map<String, Object> additionalProperties = new HashMap<String, Object>();
73 protected final static Object NOT_FOUND_VALUE = new Object();
76 * No args constructor for use in serialization
79 public PdpdConfiguration() {
88 public PdpdConfiguration(String requestID, String entity, List<ControllerConfiguration> controllers) {
89 this.requestID = requestID;
91 this.controllers = controllers;
95 * Unique Transaction ID. This is an UUID.
101 @JsonProperty("requestID")
102 public String getRequestID() {
107 * Unique Transaction ID. This is an UUID.
113 @JsonProperty("requestID")
114 public void setRequestID(String requestID) {
115 this.requestID = requestID;
118 public PdpdConfiguration withRequestID(String requestID) {
119 this.requestID = requestID;
124 * Set of entities on which configuration can be performed: controller
130 @JsonProperty("entity")
131 public String getEntity() {
136 * Set of entities on which configuration can be performed: controller
142 @JsonProperty("entity")
143 public void setEntity(String entity) {
144 this.entity = entity;
147 public PdpdConfiguration withEntity(String entity) {
148 this.entity = entity;
153 * Controller Information, only applicable when the entity is set to controller
158 @JsonProperty("controller")
159 public List<ControllerConfiguration> getControllers() {
164 * Controller Information, only applicable when the entity is set to controller
169 @JsonProperty("controller")
170 public void setControllers(List<ControllerConfiguration> controllers) {
171 this.controllers = controllers;
174 public PdpdConfiguration withController(List<ControllerConfiguration> controllers) {
175 this.controllers = controllers;
180 public String toString() {
181 return ToStringBuilder.reflectionToString(this);
185 public Map<String, Object> getAdditionalProperties() {
186 return this.additionalProperties;
190 public void setAdditionalProperty(String name, Object value) {
191 this.additionalProperties.put(name, value);
194 public PdpdConfiguration withAdditionalProperty(String name, Object value) {
195 this.additionalProperties.put(name, value);
199 @SuppressWarnings("unchecked")
200 protected boolean declaredProperty(String name, Object value) {
203 if (value instanceof String) {
204 setRequestID(((String) value));
206 throw new IllegalArgumentException(("property \"requestID\" is of type \"java.lang.String\", but got "+ value.getClass().toString()));
210 if (value instanceof String) {
211 setEntity(((String) value));
213 throw new IllegalArgumentException(("property \"entity\" is of type \"java.lang.String\", but got "+ value.getClass().toString()));
217 if (value instanceof List) {
218 setControllers(((List<ControllerConfiguration> ) value));
220 throw new IllegalArgumentException(("property \"controllers\" is of type \"java.util.List<org.onap.policy.drools.protocol.configuration.Controller>\", but got "+ value.getClass().toString()));
228 protected Object declaredPropertyOrNotFound(String name, Object notFoundValue) {
231 return getRequestID();
235 return getControllers();
237 return notFoundValue;
244 public<T >T get(String name) {
245 Object value = declaredPropertyOrNotFound(name, PdpdConfiguration.NOT_FOUND_VALUE);
246 if (PdpdConfiguration.NOT_FOUND_VALUE!= value) {
249 return ((T) getAdditionalProperties().get(name));
253 public void set(String name, Object value) {
254 if (!declaredProperty(name, value)) {
255 getAdditionalProperties().put(name, ((Object) value));
259 public PdpdConfiguration with(String name, Object value) {
260 if (!declaredProperty(name, value)) {
261 getAdditionalProperties().put(name, ((Object) value));
267 public int hashCode() {
268 return new HashCodeBuilder().append(requestID).append(entity).append(controllers).append(additionalProperties).toHashCode();
272 public boolean equals(Object other) {
276 if ((other instanceof PdpdConfiguration) == false) {
279 PdpdConfiguration rhs = ((PdpdConfiguration) other);
280 return new EqualsBuilder().append(requestID, rhs.requestID).append(entity, rhs.entity).append(controllers, rhs.controllers).append(additionalProperties, rhs.additionalProperties).isEquals();