1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.dishevelled.codegen;
25
26
27
28
29
30
31
32
33
34 public final class Association
35 {
36
37 private final String lower;
38
39
40 private final String mixed;
41
42
43 private final String upper;
44
45
46 private final String packageName;
47
48
49 private final String description;
50
51
52 private final Role role;
53
54
55 private final Cardinality cardinality;
56
57
58 private final CollectionDescription collectionDescription;
59
60
61 private final boolean bound;
62
63
64
65
66
67
68
69
70
71
72
73
74 public Association(final ClassDescription cd,
75 final String roleName,
76 final Cardinality cardinality)
77 {
78 if ((cardinality == Cardinality.ZeroToMany) || (cardinality == Cardinality.OneToMany))
79 {
80 throw new IllegalArgumentException("cardinality must be one of {ZeroToOne, StrictlyOne}");
81 }
82
83 this.lower = cd.getLower();
84 this.mixed = cd.getMixed();
85 this.upper = cd.getUpper();
86 this.description = cd.getDescription();
87 this.packageName = cd.getPackageName();
88
89 this.role = new Role(roleName);
90
91 this.cardinality = cardinality;
92 this.collectionDescription = null;
93 this.bound = false;
94 }
95
96
97
98
99
100
101
102
103
104
105
106
107 public Association(final ClassDescription cd,
108 final String roleName,
109 final Cardinality cardinality,
110 final boolean bound)
111 {
112 if ((cardinality == Cardinality.ZeroToMany) || (cardinality == Cardinality.OneToMany))
113 {
114 throw new IllegalArgumentException("cardinality must be one of {ZeroToOne, StrictlyOne}");
115 }
116
117 this.lower = cd.getLower();
118 this.mixed = cd.getMixed();
119 this.upper = cd.getUpper();
120 this.description = cd.getDescription();
121 this.packageName = cd.getPackageName();
122
123 this.role = new Role(roleName);
124
125 this.cardinality = cardinality;
126 this.collectionDescription = null;
127 this.bound = bound;
128 }
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145 public Association(final ClassDescription cd,
146 final String roleName,
147 final Cardinality cardinality,
148 final boolean indexed,
149 final boolean unique,
150 final boolean ordered,
151 final boolean sorted)
152 {
153 this.lower = cd.getLower();
154 this.mixed = cd.getMixed();
155 this.upper = cd.getUpper();
156 this.description = cd.getDescription();
157 this.packageName = cd.getPackageName();
158
159 this.role = new Role(roleName);
160
161 this.cardinality = cardinality;
162 if ((cardinality == Cardinality.ZeroToMany) || (cardinality == Cardinality.OneToMany))
163 {
164 this.collectionDescription = CollectionDescription.choose(indexed, unique, ordered, sorted);
165 }
166 else
167 {
168 this.collectionDescription = null;
169 }
170 this.bound = false;
171 }
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189 public Association(final ClassDescription cd,
190 final String roleName,
191 final Cardinality cardinality,
192 final boolean bound,
193 final boolean indexed,
194 final boolean unique,
195 final boolean ordered,
196 final boolean sorted)
197 {
198 this.lower = cd.getLower();
199 this.mixed = cd.getMixed();
200 this.upper = cd.getUpper();
201 this.description = cd.getDescription();
202 this.packageName = cd.getPackageName();
203
204 this.role = new Role(roleName);
205
206 this.cardinality = cardinality;
207 if ((cardinality == Cardinality.ZeroToMany) || (cardinality == Cardinality.OneToMany))
208 {
209 this.collectionDescription = CollectionDescription.choose(indexed, unique, ordered, sorted);
210 }
211 else
212 {
213 this.collectionDescription = null;
214 }
215 this.bound = bound;
216 }
217
218
219
220
221
222
223
224
225
226
227
228 public Association(final InterfaceDescription id,
229 final String roleName,
230 final Cardinality cardinality)
231 {
232 if ((cardinality == Cardinality.ZeroToMany) || (cardinality == Cardinality.OneToMany))
233 {
234 throw new IllegalArgumentException("cardinality must be one of {ZeroToOne, StrictlyOne}");
235 }
236
237 this.lower = id.getLower();
238 this.mixed = id.getMixed();
239 this.upper = id.getUpper();
240 this.description = id.getDescription();
241 this.packageName = id.getPackageName();
242
243 this.role = new Role(roleName);
244
245 this.cardinality = cardinality;
246 this.collectionDescription = null;
247 this.bound = false;
248 }
249
250
251
252
253
254
255
256
257
258
259
260
261 public Association(final InterfaceDescription id,
262 final String roleName,
263 final Cardinality cardinality,
264 final boolean bound)
265 {
266 if ((cardinality == Cardinality.ZeroToMany) || (cardinality == Cardinality.OneToMany))
267 {
268 throw new IllegalArgumentException("cardinality must be one of {ZeroToOne, StrictlyOne}");
269 }
270
271 this.lower = id.getLower();
272 this.mixed = id.getMixed();
273 this.upper = id.getUpper();
274 this.description = id.getDescription();
275 this.packageName = id.getPackageName();
276
277 this.role = new Role(roleName);
278
279 this.cardinality = cardinality;
280 this.collectionDescription = null;
281 this.bound = bound;
282 }
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299 public Association(final InterfaceDescription id,
300 final String roleName,
301 final Cardinality cardinality,
302 final boolean indexed,
303 final boolean unique,
304 final boolean ordered,
305 final boolean sorted)
306 {
307 this.lower = id.getLower();
308 this.mixed = id.getMixed();
309 this.upper = id.getUpper();
310 this.description = id.getDescription();
311 this.packageName = id.getPackageName();
312
313 this.role = new Role(roleName);
314
315 this.cardinality = cardinality;
316 if ((cardinality == Cardinality.ZeroToMany) || (cardinality == Cardinality.OneToMany))
317 {
318 this.collectionDescription = CollectionDescription.choose(indexed, unique, ordered, sorted);
319 }
320 else
321 {
322 this.collectionDescription = null;
323 }
324 this.bound = false;
325 }
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343 public Association(final InterfaceDescription id,
344 final String roleName,
345 final Cardinality cardinality,
346 final boolean bound,
347 final boolean indexed,
348 final boolean unique,
349 final boolean ordered,
350 final boolean sorted)
351 {
352 this.lower = id.getLower();
353 this.mixed = id.getMixed();
354 this.upper = id.getUpper();
355 this.description = id.getDescription();
356 this.packageName = id.getPackageName();
357
358 this.role = new Role(roleName);
359
360 this.cardinality = cardinality;
361 if ((cardinality == Cardinality.ZeroToMany) || (cardinality == Cardinality.OneToMany))
362 {
363 this.collectionDescription = CollectionDescription.choose(indexed, unique, ordered, sorted);
364 }
365 else
366 {
367 this.collectionDescription = null;
368 }
369 this.bound = bound;
370 }
371
372
373
374
375
376
377
378
379
380
381
382
383 public Association(final String lower,
384 final String mixed,
385 final String upper,
386 final String description,
387 final Role role,
388 final Cardinality cardinality,
389 final CollectionDescription collectionDescription)
390 {
391 if (role == null)
392 {
393 throw new IllegalArgumentException("role must not be null");
394 }
395 if (cardinality == null)
396 {
397 throw new IllegalArgumentException("cardinality must not be null");
398 }
399
400 this.lower = lower;
401 this.mixed = mixed;
402 this.upper = upper;
403 this.description = description;
404 this.packageName = "";
405 this.role = role;
406 this.cardinality = cardinality;
407 this.collectionDescription = collectionDescription;
408 this.bound = false;
409 }
410
411
412
413
414
415
416
417
418
419
420
421
422
423 public Association(final String lower,
424 final String mixed,
425 final String upper,
426 final String description,
427 final Role role,
428 final Cardinality cardinality,
429 final CollectionDescription collectionDescription,
430 final boolean bound)
431 {
432 if (role == null)
433 {
434 throw new IllegalArgumentException("role must not be null");
435 }
436 if (cardinality == null)
437 {
438 throw new IllegalArgumentException("cardinality must not be null");
439 }
440
441 this.lower = lower;
442 this.mixed = mixed;
443 this.upper = upper;
444 this.description = description;
445 this.packageName = "";
446 this.role = role;
447 this.cardinality = cardinality;
448 this.collectionDescription = collectionDescription;
449 this.bound = bound;
450 }
451
452
453
454
455
456
457
458 public String getLower()
459 {
460 return lower;
461 }
462
463
464
465
466
467
468 public String getMixed()
469 {
470 return mixed;
471 }
472
473
474
475
476
477
478 public String getUpper()
479 {
480 return upper;
481 }
482
483
484
485
486
487
488 public String getDescription()
489 {
490 return description;
491 }
492
493
494
495
496
497
498 public String getPackageName()
499 {
500 return packageName;
501 }
502
503
504
505
506
507
508 public Role getRole()
509 {
510 return role;
511 }
512
513
514
515
516
517
518 public Cardinality getCardinality()
519 {
520 return cardinality;
521 }
522
523
524
525
526
527
528
529 public CollectionDescription getCollectionDescription()
530 {
531 return collectionDescription;
532 }
533
534
535
536
537
538
539 public boolean isBound()
540 {
541 return bound;
542 }
543 }