2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
24 package org.onap.clamp.clds.tosca.update.templates;
26 public class JsonTemplateField {
29 private Boolean visible;
30 private Boolean staticValue;
32 public JsonTemplateField(String title) {
39 * @param title The title
40 * @param value The value
41 * @param visible visible or not
42 * @param staticValue The static value
44 public JsonTemplateField(String title, Object value, Boolean visible, Boolean staticValue) {
47 this.visible = visible;
48 this.staticValue = staticValue;
51 public String getTitle() {
55 public void setTitle(String title) {
59 public Object getValue() {
63 public void setValue(Object value) {
67 public Boolean getVisible() {
71 public void setVisible(Boolean visible) {
72 this.visible = visible;
75 public Boolean getStaticValue() {
79 public void setStaticValue(Boolean staticValue) {
80 this.staticValue = staticValue;
83 public String toString() {
84 return title + " " + value + " " + visible + " " + staticValue;
88 * This method compares two fields.
90 * @param otherField Compare the current object with the one specified
91 * @return true if they are totally equals, false otherwise
93 public boolean compareWithField(Object otherField) {
94 if (this == otherField) {
97 if (otherField == null || getClass() != otherField.getClass()) {
101 JsonTemplateField jsonTemplateField = (JsonTemplateField) otherField;
103 if (title != null ? !title.equals(jsonTemplateField.title) : jsonTemplateField.title != null) {
106 if (value != null ? !value.equals(jsonTemplateField.value) : jsonTemplateField.value != null) {
109 if (visible != null ? !visible.equals(jsonTemplateField.visible) : jsonTemplateField.visible != null) {
112 return staticValue != null ? staticValue.equals(jsonTemplateField.staticValue) :
113 jsonTemplateField.staticValue == null;
117 public boolean equals(Object object) {
118 if (this == object) {
121 if (object == null || getClass() != object.getClass()) {
125 JsonTemplateField jsonTemplateField = (JsonTemplateField) object;
127 return title != null ? title.equals(jsonTemplateField.title) : jsonTemplateField.title == null;
131 public int hashCode() {
132 return title != null ? title.hashCode() : 0;
136 * This method test the entire equality.
138 * @param jsonTemplateField1 object one
139 * @param jsonTemplateField2 object two
140 * @return true if they are totally equals (all attributes, false otherwise
142 public static boolean fieldsEquals(JsonTemplateField jsonTemplateField1, JsonTemplateField jsonTemplateField2) {
143 return (jsonTemplateField2.getTitle().equals(jsonTemplateField1.getTitle())
144 && jsonTemplateField2.getValue().equals(jsonTemplateField1.getValue())
145 && jsonTemplateField2.getVisible().equals(jsonTemplateField1.getVisible())
146 && jsonTemplateField2.getStaticValue().equals(jsonTemplateField1.getStaticValue()));