1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package pl.edu.agh.cast.model;
19
20 import java.util.Arrays;
21
22
23
24
25
26
27
28 public class ModelColumn {
29
30 private String id;
31
32 private String name;
33
34 private int modelIndex;
35
36 private String type;
37
38 private boolean required;
39
40 private String defaultValue;
41
42 private ModelColumnParameter[] parameters;
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62 public ModelColumn(String id, String name, int modelIndex, String type, boolean required, String defaultValue) {
63 this.id = id;
64 this.name = name;
65 this.modelIndex = modelIndex;
66 this.type = type;
67 this.required = required;
68 this.defaultValue = defaultValue;
69 }
70
71
72
73
74
75
76
77 @Override
78 public boolean equals(Object obj) {
79 if (this == obj) {
80 return true;
81 }
82
83 if (!(obj instanceof ModelColumn)) {
84 return false;
85 }
86 ModelColumn other = (ModelColumn)obj;
87
88 if (id == null) {
89 if (other.id != null) {
90 return false;
91 }
92 } else if (!id.equals(other.id)) {
93 return false;
94 }
95 if (name == null) {
96 if (other.name != null) {
97 return false;
98 }
99 } else if (!name.equals(other.name)) {
100 return false;
101 }
102 if (modelIndex != other.modelIndex) {
103 return false;
104 }
105 if (type == null) {
106 if (other.type != null) {
107 return false;
108 }
109 } else if (!type.equals(other.type)) {
110 return false;
111 }
112 if (required != other.required) {
113 return false;
114 }
115 if (defaultValue == null) {
116 if (other.defaultValue != null) {
117 return false;
118 }
119 } else if (!defaultValue.equals(other.defaultValue)) {
120 return false;
121 }
122 if (!Arrays.equals(parameters, other.parameters)) {
123 return false;
124 }
125
126 return true;
127 }
128
129
130
131
132
133
134
135 @Override
136 public int hashCode() {
137 StringBuilder hash = new StringBuilder();
138 if (id != null) {
139 hash.append(id);
140 }
141 if (name != null) {
142 hash.append(name);
143 }
144 if (modelIndex != -1) {
145 hash.append(modelIndex);
146 }
147 if (type != null) {
148 hash.append(type);
149 }
150 hash.append(required);
151 if (defaultValue != null) {
152 hash.append(defaultValue);
153 }
154 hash.append(Arrays.hashCode(parameters));
155 return hash.toString().hashCode();
156 }
157
158 public void setParameters(ModelColumnParameter[] newParameters) {
159 parameters = newParameters;
160 }
161
162 public String getId() {
163 return id;
164 }
165
166 public String getName() {
167 return name;
168 }
169
170 public int getModelIndex() {
171 return modelIndex;
172 }
173
174 public String getType() {
175 return type;
176 }
177
178 public boolean isRequired() {
179 return required;
180 }
181
182 public String getDefaultValue() {
183 return defaultValue;
184 }
185
186 public ModelColumnParameter[] getParameters() {
187 return parameters;
188 }
189
190 }