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.HashMap;
26 import org.apache.commons.lang3.builder.EqualsBuilder;
27 import org.apache.commons.lang3.builder.HashCodeBuilder;
28 import org.apache.commons.lang3.builder.ToStringBuilder;
30 import com.fasterxml.jackson.annotation.JsonAnyGetter;
31 import com.fasterxml.jackson.annotation.JsonAnySetter;
32 import com.fasterxml.jackson.annotation.JsonIgnore;
33 import com.fasterxml.jackson.annotation.JsonInclude;
34 import com.fasterxml.jackson.annotation.JsonProperty;
38 * Maven Related Information
41 @JsonInclude(JsonInclude.Include.NON_NULL)
42 public class DroolsConfiguration {
49 @JsonProperty("artifactId")
50 private String artifactId;
56 @JsonProperty("groupId")
57 private String groupId;
63 @JsonProperty("version")
64 private String version;
66 private Map<String, Object> additionalProperties = new HashMap<>();
67 protected final static Object NOT_FOUND_VALUE = new Object();
70 * No args constructor for use in serialization
73 public DroolsConfiguration() {
83 public DroolsConfiguration(String artifactId, String groupId, String version) {
84 this.artifactId = artifactId;
85 this.groupId = groupId;
86 this.version = version;
96 @JsonProperty("artifactId")
97 public String getArtifactId() {
108 @JsonProperty("artifactId")
109 public void setArtifactId(String artifactId) {
110 this.artifactId = artifactId;
113 public DroolsConfiguration withArtifactId(String artifactId) {
114 this.artifactId = artifactId;
125 @JsonProperty("groupId")
126 public String getGroupId() {
137 @JsonProperty("groupId")
138 public void setGroupId(String groupId) {
139 this.groupId = groupId;
142 public DroolsConfiguration withGroupId(String groupId) {
143 this.groupId = groupId;
154 @JsonProperty("version")
155 public String getVersion() {
166 @JsonProperty("version")
167 public void setVersion(String version) {
168 this.version = version;
171 public DroolsConfiguration withVersion(String version) {
172 this.version = version;
177 public String toString() {
178 return ToStringBuilder.reflectionToString(this);
182 public Map<String, Object> getAdditionalProperties() {
183 return this.additionalProperties;
187 public void setAdditionalProperty(String name, Object value) {
188 this.additionalProperties.put(name, value);
191 public DroolsConfiguration withAdditionalProperty(String name, Object value) {
192 this.additionalProperties.put(name, value);
196 protected boolean declaredProperty(String name, Object value) {
199 callSetArtifactId(value);
202 callSetGroupId(value);
205 callSetVersion(value);
212 protected Object declaredPropertyOrNotFound(String name, Object notFoundValue) {
215 return getArtifactId();
221 return notFoundValue;
228 public<T >T get(String name) {
229 Object value = declaredPropertyOrNotFound(name, DroolsConfiguration.NOT_FOUND_VALUE);
230 if (DroolsConfiguration.NOT_FOUND_VALUE!= value) {
233 return (T) getAdditionalProperties().get(name);
237 public void set(String name, Object value) {
238 if (!declaredProperty(name, value)) {
239 getAdditionalProperties().put(name, value);
243 public DroolsConfiguration with(String name, Object value) {
244 if (!declaredProperty(name, value)) {
245 getAdditionalProperties().put(name, value);
251 public int hashCode() {
252 return new HashCodeBuilder().append(artifactId).append(groupId).append(version).append(additionalProperties).toHashCode();
256 public boolean equals(Object other) {
260 if ((other instanceof DroolsConfiguration) == false) {
263 DroolsConfiguration rhs = ((DroolsConfiguration) other);
264 return new EqualsBuilder().append(artifactId, rhs.artifactId).append(groupId, rhs.groupId).append(version, rhs.version).append(additionalProperties, rhs.additionalProperties).isEquals();
267 public void callSetArtifactId(Object value) {
268 if (value instanceof String) {
269 setArtifactId((String) value);
271 throw new IllegalArgumentException("property \"artifactId\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
275 public void callSetGroupId(Object value) {
276 if (value instanceof String) {
277 setGroupId((String) value);
279 throw new IllegalArgumentException("property \"groupId\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
283 public void callSetVersion(Object value) {
284 if (value instanceof String) {
285 setVersion((String) value);
287 throw new IllegalArgumentException("property \"version\" is of type \"java.lang.String\", but got "+ value.getClass().toString());