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.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  * Drools Related Information
 
  41 @JsonInclude(JsonInclude.Include.NON_NULL)
 
  42 public class ControllerConfiguration {
 
  44         public static final String CONFIG_CONTROLLER_OPERATION_CREATE = "create";
 
  45         public static final String CONFIG_CONTROLLER_OPERATION_UPDATE = "update";
 
  46         public static final String CONFIG_CONTROLLER_OPERATION_LOCK = "lock";
 
  47         public static final String CONFIG_CONTROLLER_OPERATION_UNLOCK = "unlock";
 
  57      * Set of operations that can be applied to a controller: create, lock
 
  61     @JsonProperty("operation")
 
  62     private String operation;
 
  64      * Maven Related Information
 
  67     @JsonProperty("drools")
 
  68     private DroolsConfiguration drools;
 
  70     private Map<String, Object> additionalProperties = new HashMap<>();
 
  71     protected static final Object NOT_FOUND_VALUE = new Object();
 
  74      * No args constructor for use in serialization
 
  77     public ControllerConfiguration() {
 
  87     public ControllerConfiguration(String name, String operation, DroolsConfiguration drools) {
 
  89         this.operation = operation;
 
 100     @JsonProperty("name")
 
 101     public String getName() {
 
 112     @JsonProperty("name")
 
 113     public void setName(String name) {
 
 117     public ControllerConfiguration withName(String name) {
 
 123      * Set of operations that can be applied to a controller: create, lock
 
 129     @JsonProperty("operation")
 
 130     public String getOperation() {
 
 135      * Set of operations that can be applied to a controller: create, lock
 
 141     @JsonProperty("operation")
 
 142     public void setOperation(String operation) {
 
 143         this.operation = operation;
 
 146     public ControllerConfiguration withOperation(String operation) {
 
 147         this.operation = operation;
 
 152      * Maven Related Information
 
 157     @JsonProperty("drools")
 
 158     public DroolsConfiguration getDrools() {
 
 163      * Maven Related Information
 
 168     @JsonProperty("drools")
 
 169     public void setDrools(DroolsConfiguration drools) {
 
 170         this.drools = drools;
 
 173     public ControllerConfiguration withDrools(DroolsConfiguration drools) {
 
 174         this.drools = drools;
 
 179     public String toString() {
 
 180         return ToStringBuilder.reflectionToString(this);
 
 184     public Map<String, Object> getAdditionalProperties() {
 
 185         return this.additionalProperties;
 
 189     public void setAdditionalProperty(String name, Object value) {
 
 190         this.additionalProperties.put(name, value);
 
 193     public ControllerConfiguration withAdditionalProperty(String name, Object value) {
 
 194         this.additionalProperties.put(name, value);
 
 198     protected boolean declaredProperty(String name, Object value) {
 
 204                 callSetOperation(value);
 
 207                 callSetDrools(value);
 
 214     protected Object declaredPropertyOrNotFound(String name, Object notFoundValue) {
 
 219                 return getOperation();
 
 223                 return notFoundValue;
 
 230     public<T >T get(String name) {
 
 231         Object value = declaredPropertyOrNotFound(name, ControllerConfiguration.NOT_FOUND_VALUE);
 
 232         if (ControllerConfiguration.NOT_FOUND_VALUE!= value) {
 
 235             return ((T) getAdditionalProperties().get(name));
 
 239     public void set(String name, Object value) {
 
 240         if (!declaredProperty(name, value)) {
 
 241             getAdditionalProperties().put(name, (Object) value);
 
 245     public ControllerConfiguration with(String name, Object value) {
 
 246         if (!declaredProperty(name, value)) {
 
 247             getAdditionalProperties().put(name, (Object) value);
 
 253     public int hashCode() {
 
 254         return new HashCodeBuilder().append(name).append(operation).append(drools).append(additionalProperties).toHashCode();
 
 258     public boolean equals(Object other) {
 
 262         if (!(other instanceof ControllerConfiguration)) {
 
 265         ControllerConfiguration rhs = ((ControllerConfiguration) other);
 
 266         return new EqualsBuilder().append(name, rhs.name).append(operation, rhs.operation).append(drools, rhs.drools).append(additionalProperties, rhs.additionalProperties).isEquals();
 
 269     public void callSetName(Object value) {
 
 270         if (value instanceof String) {
 
 271             setName((String) value);
 
 273             throw new IllegalArgumentException("property \"name\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
 
 277     public void callSetOperation(Object value) {
 
 278         if (value instanceof String) {
 
 279             setOperation((String) value);
 
 281             throw new IllegalArgumentException("property \"operation\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
 
 285     public void callSetDrools(Object value) {
 
 286         if (value instanceof DroolsConfiguration) {
 
 287             setDrools((DroolsConfiguration) value);
 
 289             throw new IllegalArgumentException("property \"drools\" is of type \"org.onap.policy.drools.protocol.configuration.Drools\", but got "+ value.getClass().toString());