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;
26 public class TemplateField {
29 private Boolean visible;
30 private Boolean staticValue;
32 public TemplateField(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 TemplateField(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 TemplateField templateField = (TemplateField) otherField;
103 if (title != null ? !title.equals(templateField.title) : templateField.title != null) {
106 if (value != null ? !value.equals(templateField.value) : templateField.value != null) {
109 if (visible != null ? !visible.equals(templateField.visible) : templateField.visible != null) {
112 return staticValue != null ? staticValue.equals(templateField.staticValue) : templateField.staticValue == null;
116 public boolean equals(Object object) {
117 if (this == object) {
120 if (object == null || getClass() != object.getClass()) {
124 TemplateField templateField = (TemplateField) object;
126 return title != null ? title.equals(templateField.title) : templateField.title == null;
130 public int hashCode() {
131 return title != null ? title.hashCode() : 0;
135 * This method test the entire equality.
137 * @param templateField1 object one
138 * @param templateField2 object two
139 * @return true if they are totally equals (all attributes, false otherwise
141 public static boolean fieldsEquals(TemplateField templateField1, TemplateField templateField2) {
142 return (templateField2.getTitle().equals(templateField1.getTitle())
143 && templateField2.getValue().equals(templateField1.getValue())
144 && templateField2.getVisible().equals(templateField1.getVisible())
145 && templateField2.getStaticValue().equals(templateField1.getStaticValue()));