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<String, Object>();
67 protected final static Object NOT_FOUND_VALUE = new Object();
70 * No args constructor for use in serialization
73 public DroolsConfiguration() {
82 public DroolsConfiguration(String artifactId, String groupId, String version) {
83 this.artifactId = artifactId;
84 this.groupId = groupId;
85 this.version = version;
95 @JsonProperty("artifactId")
96 public String getArtifactId() {
107 @JsonProperty("artifactId")
108 public void setArtifactId(String artifactId) {
109 this.artifactId = artifactId;
112 public DroolsConfiguration withArtifactId(String artifactId) {
113 this.artifactId = artifactId;
124 @JsonProperty("groupId")
125 public String getGroupId() {
136 @JsonProperty("groupId")
137 public void setGroupId(String groupId) {
138 this.groupId = groupId;
141 public DroolsConfiguration withGroupId(String groupId) {
142 this.groupId = groupId;
153 @JsonProperty("version")
154 public String getVersion() {
165 @JsonProperty("version")
166 public void setVersion(String version) {
167 this.version = version;
170 public DroolsConfiguration withVersion(String version) {
171 this.version = version;
176 public String toString() {
177 return ToStringBuilder.reflectionToString(this);
181 public Map<String, Object> getAdditionalProperties() {
182 return this.additionalProperties;
186 public void setAdditionalProperty(String name, Object value) {
187 this.additionalProperties.put(name, value);
190 public DroolsConfiguration withAdditionalProperty(String name, Object value) {
191 this.additionalProperties.put(name, value);
195 protected boolean declaredProperty(String name, Object value) {
198 if (value instanceof String) {
199 setArtifactId(((String) value));
201 throw new IllegalArgumentException(("property \"artifactId\" is of type \"java.lang.String\", but got "+ value.getClass().toString()));
205 if (value instanceof String) {
206 setGroupId(((String) value));
208 throw new IllegalArgumentException(("property \"groupId\" is of type \"java.lang.String\", but got "+ value.getClass().toString()));
212 if (value instanceof String) {
213 setVersion(((String) value));
215 throw new IllegalArgumentException(("property \"version\" is of type \"java.lang.String\", but got "+ value.getClass().toString()));
223 protected Object declaredPropertyOrNotFound(String name, Object notFoundValue) {
226 return getArtifactId();
232 return notFoundValue;
239 public<T >T get(String name) {
240 Object value = declaredPropertyOrNotFound(name, DroolsConfiguration.NOT_FOUND_VALUE);
241 if (DroolsConfiguration.NOT_FOUND_VALUE!= value) {
244 return ((T) getAdditionalProperties().get(name));
248 public void set(String name, Object value) {
249 if (!declaredProperty(name, value)) {
250 getAdditionalProperties().put(name, ((Object) value));
254 public DroolsConfiguration with(String name, Object value) {
255 if (!declaredProperty(name, value)) {
256 getAdditionalProperties().put(name, ((Object) value));
262 public int hashCode() {
263 return new HashCodeBuilder().append(artifactId).append(groupId).append(version).append(additionalProperties).toHashCode();
267 public boolean equals(Object other) {
271 if ((other instanceof DroolsConfiguration) == false) {
274 DroolsConfiguration rhs = ((DroolsConfiguration) other);
275 return new EqualsBuilder().append(artifactId, rhs.artifactId).append(groupId, rhs.groupId).append(version, rhs.version).append(additionalProperties, rhs.additionalProperties).isEquals();