1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.logging.log4j.catalog.api;
18
19 import java.io.Serializable;
20 import java.util.Set;
21
22 import static org.apache.logging.log4j.catalog.api.constant.Constants.DEFAULT_CATALOG;
23
24
25
26
27 public class Attribute implements Serializable {
28
29 private static final long serialVersionUID = -756109102178482698L;
30 private Long id;
31 private String name;
32 private String displayName;
33 private String description;
34 private DataType dataType;
35 private boolean indexed;
36 private boolean sortable;
37 private boolean required;
38 private boolean requestContext;
39 private Set<String> examples;
40 private Set<String> aliases;
41 private Set<Constraint> constraints;
42 private String catalogId;
43
44
45
46
47 public Attribute() {
48 catalogId = DEFAULT_CATALOG;
49 }
50
51
52
53
54
55 public Long getId() {
56 return id;
57 }
58
59
60
61
62
63 public void setId(Long id) {
64 this.id = id;
65 }
66
67
68
69
70 public String getName() {
71 return name;
72 }
73
74
75
76
77
78
79 public Attribute setName(String name) {
80 this.name = name;
81 return this;
82 }
83
84
85
86
87
88 public String getDisplayName() {
89 return displayName;
90 }
91
92
93
94
95
96
97 public Attribute setDisplayName(String name) {
98 this.displayName = name;
99 return this;
100 }
101
102
103
104
105
106 public String getDescription() {
107 return description;
108 }
109
110
111
112
113
114
115 public Attribute setDescription(String description) {
116 this.description = description;
117 return this;
118 }
119
120
121
122
123
124 public DataType getDataType() {
125 return dataType;
126 }
127
128
129
130
131
132
133 public Attribute setDataType(DataType dataType) {
134 this.dataType = dataType;
135 return this;
136 }
137
138
139
140
141
142 public boolean isIndexed() {
143 return indexed;
144 }
145
146
147
148
149
150
151 public Attribute setIndexed(boolean indexed) {
152 this.indexed = indexed;
153 return this;
154 }
155
156
157
158
159
160 public boolean isSortable() {
161 return sortable;
162 }
163
164
165
166
167
168
169 public Attribute setSortable(boolean sortable) {
170 this.sortable = sortable;
171 return this;
172 }
173
174
175
176
177
178 public boolean isRequired() {
179 return required;
180 }
181
182
183
184
185
186
187 public Attribute setRequired(boolean required) {
188 this.required = required;
189 return this;
190 }
191
192
193
194
195
196 public boolean isRequestContext() {
197 return requestContext;
198 }
199
200
201
202
203
204
205 public Attribute setRequestContext(boolean isRequestContext) {
206 this.requestContext = isRequestContext;
207 return this;
208 }
209
210
211
212
213
214 public Set<String> getExamples() {
215 return examples;
216 }
217
218
219
220
221
222
223 public Attribute setExamples(Set<String> examples) {
224 this.examples = examples;
225 return this;
226 }
227
228
229
230
231
232 public Set<String> getAliases() {
233 return aliases;
234 }
235
236
237
238
239
240
241 public Attribute setAliases(Set<String> aliases) {
242 this.aliases = aliases;
243 return this;
244 }
245
246
247
248
249
250 public Set<Constraint> getConstraints() {
251 return constraints;
252 }
253
254
255
256
257
258
259 public Attribute setConstraints(Set<Constraint> constraints) {
260 this.constraints = constraints;
261 return this;
262 }
263
264
265
266
267
268 public String getCatalogId() {
269 return catalogId;
270 }
271
272
273
274
275
276 public void setCatalogId(String catalogId) {
277 this.catalogId = catalogId;
278 }
279
280 @Override
281 public String toString() {
282 StringBuilder sb = new StringBuilder("{");
283 sb.append("id=\"").append(id).append("\" ");
284 sb.append("catalog id=\"").append(catalogId).append("\" ");
285 sb.append("name=\"").append(name).append("\" ");
286 sb.append("displayName=\"").append(displayName).append("\" ");
287 sb.append("description=\"").append(description).append("\" ");
288 sb.append("dataType=\"");
289 if (dataType == null) {
290 sb.append("null");
291 } else {
292 sb.append(dataType.getTypeName());
293 }
294 sb.append("\" ");
295 sb.append("indexed=\"").append(indexed).append("\" ");
296 sb.append("sortable=\"").append(sortable).append("\" ");
297 sb.append("required=\"").append(required).append("\" ");
298 sb.append("requestContext=\"").append(requestContext).append("\" ");
299 if (constraints != null) {
300 sb.append("constraints[");
301 boolean first = true;
302 for (Constraint constraint : constraints) {
303 if (!first) {
304 sb.append(" ");
305 }
306 sb.append("name=\"").append(constraint.getConstraintType().getName()).append("\"");
307 sb.append("value=\"").append(constraint.getValue()).append("\"");
308 }
309 sb.append("]");
310 }
311 sb.append("}");
312 return sb.toString();
313 }
314 }