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