1 /*
2
3 dsh-codegen Source code generation suite.
4 Copyright (c) 2004-2011 held jointly by the individual authors.
5
6 This library is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 3 of the License, or (at
9 your option) any later version.
10
11 This library is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this library; if not, write to the Free Software Foundation,
18 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19
20 > http://www.fsf.org/licensing/licenses/lgpl.html
21 > http://www.opensource.org/licenses/lgpl-license.php
22
23 */
24 package org.dishevelled.codegen;
25
26 import java.util.Set;
27 import java.util.LinkedHashSet;
28 import java.util.Collections;
29
30 /**
31 * A description of the attributes and associations for a class.
32 *
33 * @author Michael Heuer
34 * @version $Revision: 993 $ $Date: 2011-02-25 14:18:11 -0600 (Fri, 25 Feb 2011) $
35 */
36 public final class ClassDescription
37 {
38 /** License for this class description. */
39 private String license;
40
41 /** Package name for this class description. */
42 private String packageName;
43
44 /** Lowercase name for this class description. */
45 private String lower;
46
47 /** Mixed-case name for this class description. */
48 private String mixed;
49
50 /** Uppercase name for this class description. */
51 private String upper;
52
53 /** Author for this class description. */
54 private String author;
55
56 /** Version for this class description. */
57 private String version;
58
59 /** Description for this class description. */
60 private String description;
61
62 /** Set of classes this class description specializes. */
63 private final Set<ClassDescription> specializes;
64
65 /** Set of interfaces this class description realizes. */
66 private final Set<InterfaceDescription> realizes;
67
68 /** Set of attributes for this class description. */
69 private final Set<Attribute> attributes;
70
71 /** Set of associations for this class description. */
72 private final Set<Association> associations;
73
74
75 /**
76 * Create a new class description with the specified package name
77 * and name.
78 *
79 * @param packageName package name for this class description
80 * @param name name of this class description
81 */
82 public ClassDescription(final String packageName, final String name)
83 {
84 this.packageName = packageName;
85 this.lower = CodegenUtils.makeLowercase(name);
86 this.mixed = CodegenUtils.makeMixedCase(name);
87 this.upper = CodegenUtils.makeUppercase(name);
88 this.description = CodegenUtils.makeSentenceCaseDescription(name);
89 this.author = " codegen";
90 this.version = "$" + "Revision$ $" + "Date$"; // split to prevent svn expansion
91 this.specializes = new LinkedHashSet<ClassDescription>();
92 this.realizes = new LinkedHashSet<InterfaceDescription>();
93 this.attributes = new LinkedHashSet<Attribute>();
94 this.associations = new LinkedHashSet<Association>();
95 }
96
97 /**
98 * Create a new class description with the specified package name
99 * and name.
100 *
101 * @param license license for this class description
102 * @param packageName package name for this class description
103 * @param name name of this class description
104 */
105 public ClassDescription(final String license, final String packageName, final String name)
106 {
107 this.license = license;
108 this.packageName = packageName;
109 this.lower = CodegenUtils.makeLowercase(name);
110 this.mixed = CodegenUtils.makeMixedCase(name);
111 this.upper = CodegenUtils.makeUppercase(name);
112 this.description = CodegenUtils.makeSentenceCaseDescription(name);
113 this.author = " codegen";
114 this.version = "$" + "Revision$ $" + "Date$"; // split to prevent svn expansion
115 this.specializes = new LinkedHashSet<ClassDescription>();
116 this.realizes = new LinkedHashSet<InterfaceDescription>();
117 this.attributes = new LinkedHashSet<Attribute>();
118 this.associations = new LinkedHashSet<Association>();
119 }
120
121 /**
122 * Create a new class description from the specified parameters.
123 *
124 * @param packageName package name for this class description
125 * @param name name of this class description
126 * @param author author for this class description
127 * @param version version for this class description
128 * @param description description for this class description
129 */
130 public ClassDescription(final String packageName, final String name,
131 final String author, final String version, final String description)
132 {
133 this.packageName = packageName;
134 this.lower = CodegenUtils.makeLowercase(name);
135 this.mixed = CodegenUtils.makeMixedCase(name);
136 this.upper = CodegenUtils.makeUppercase(name);
137 this.author = author;
138 this.version = version;
139 this.description = description;
140 this.specializes = new LinkedHashSet<ClassDescription>();
141 this.realizes = new LinkedHashSet<InterfaceDescription>();
142 this.attributes = new LinkedHashSet<Attribute>();
143 this.associations = new LinkedHashSet<Association>();
144 }
145
146 /**
147 * Create a new class description from the specified parameters.
148 *
149 * @param packageName package name for this class description
150 * @param lower lowercase name for this class description
151 * @param mixed mixed-case name for this class description
152 * @param upper uppercase name for this class description
153 * @param author author for this class description
154 * @param version version for this class description
155 * @param description description for this class description
156 */
157 public ClassDescription(final String packageName, final String lower, final String mixed, final String upper,
158 final String author, final String version, final String description)
159 {
160 this.packageName = packageName;
161 this.lower = lower;
162 this.mixed = mixed;
163 this.upper = upper;
164 this.author = author;
165 this.version = version;
166 this.description = description;
167 this.specializes = new LinkedHashSet<ClassDescription>();
168 this.realizes = new LinkedHashSet<InterfaceDescription>();
169 this.attributes = new LinkedHashSet<Attribute>();
170 this.associations = new LinkedHashSet<Association>();
171 }
172
173 /**
174 * Create a new class description from the specified parameters.
175 *
176 * <p>The classes this class description specializes in <code>specializes</code> are copied defensively
177 * into this class.</p>
178 *
179 * <p>The interfaces this class description realizes in <code>realizes</code> are copied defensively
180 * into this class.</p>
181 *
182 * <p>The attributes in <code>attributes</code> are copied defensively
183 * into this class.</p>
184 *
185 * <p>The associations in <code>associations</code> are copied defensively
186 * into this class.</p>
187 *
188 * @param packageName package name for this class description
189 * @param lower lowercase name for this class description
190 * @param mixed mixed-case name for this class description
191 * @param upper uppercase name for this class description
192 * @param author author for this class description
193 * @param version version for this class description
194 * @param description description for this class description
195 * @param specializes set of classes this class description specializes, must not be null
196 * @param realizes set of interfaces this class description realizes, must not be null
197 * @param attributes set of attributes, must not be null
198 * @param associations set of associations, must not be null
199 */
200 public ClassDescription(final String packageName,
201 final String lower,
202 final String mixed,
203 final String upper,
204 final String author,
205 final String version,
206 final String description,
207 final Set<ClassDescription> specializes,
208 final Set<InterfaceDescription> realizes,
209 final Set<Attribute> attributes,
210 final Set<Association> associations)
211 {
212
213 this.packageName = packageName;
214 this.lower = lower;
215 this.mixed = mixed;
216 this.upper = upper;
217 this.author = author;
218 this.version = version;
219 this.description = description;
220
221 this.specializes = new LinkedHashSet<ClassDescription>(specializes.size());
222 this.specializes.addAll(specializes);
223
224 this.realizes = new LinkedHashSet<InterfaceDescription>(realizes.size());
225 this.realizes.addAll(realizes);
226
227 this.attributes = new LinkedHashSet<Attribute>(attributes.size());
228 this.attributes.addAll(attributes);
229
230 this.associations = new LinkedHashSet<Association>(associations.size());
231 this.associations.addAll(associations);
232 }
233
234
235 /**
236 * Return the license for this class description.
237 *
238 * @return the license for this class description
239 */
240 public String getLicense()
241 {
242 return license;
243 }
244
245 /**
246 * Return the package name for this class description.
247 *
248 * @return the package name for this class description
249 */
250 public String getPackageName()
251 {
252 return packageName;
253 }
254
255 /**
256 * Return the lowercase name for this class description.
257 *
258 * @return the lowercase name for this class description
259 */
260 public String getLower()
261 {
262 return lower;
263 }
264
265 /**
266 * Return the mixed-case name for this class description.
267 *
268 * @return the mixed-case name for this class description
269 */
270 public String getMixed()
271 {
272 return mixed;
273 }
274
275 /**
276 * Return the uppercase name for this class description.
277 *
278 * @return the uppercase name for this class description
279 */
280 public String getUpper()
281 {
282 return upper;
283 }
284
285 /**
286 * Return the author for this class description.
287 *
288 * @return the author for this class description
289 */
290 public String getAuthor()
291 {
292 return author;
293 }
294
295 /**
296 * Return the version for this class description.
297 *
298 * @return the version for this class description
299 */
300 public String getVersion()
301 {
302 return version;
303 }
304
305 /**
306 * Return the description for this class description.
307 *
308 * @return the description for this class description
309 */
310 public String getDescription()
311 {
312 return description;
313 }
314
315 /**
316 * Return an unmodifiable set of classes this class description specializes.
317 *
318 * @return an unmodifiable set of classes this class description specializes
319 */
320 public Set<ClassDescription> getSpecializes()
321 {
322 return Collections.unmodifiableSet(specializes);
323 }
324
325 /**
326 * Add the specified class description to the set of classes this class description
327 * specializes. Return <code>true</code> if the set of classes this class description
328 * specializes changed as a result of this call.
329 *
330 * @param specializes class description to add, must not be null
331 * @return <code>true</code> if the set of classes this class description specializes
332 * changed as a result of this call
333 */
334 public boolean addSpecializes(final ClassDescription specializes)
335 {
336 if (specializes == null)
337 {
338 throw new IllegalArgumentException("specializes must not be null");
339 }
340
341 boolean rv = this.specializes.add(specializes);
342
343 if (rv)
344 {
345 for (Attribute a : specializes.getAttributes())
346 {
347 addAttribute(a);
348 }
349 for (Association a : specializes.getAssociations())
350 {
351 addAssociation(a);
352 }
353 }
354 return rv;
355 }
356
357 /**
358 * Add the specified class description to the set of classes this class description
359 * specializes. Return <code>true</code> if the set of classes this class description
360 * specializes changed as a result of this call.
361 *
362 * @param specializes class description to add, must not be null
363 * @return <code>true</code> if the set of classes this class description specializes
364 * changed as a result of this call
365 */
366 public boolean specializes(final ClassDescription specializes)
367 {
368 return addSpecializes(specializes);
369 }
370
371 /**
372 * Return an unmodifiable set of interfaces this class description realizes.
373 *
374 * @return an unmodifiable set of interfaces this class description realizes
375 */
376 public Set<InterfaceDescription> getRealizes()
377 {
378 return Collections.unmodifiableSet(realizes);
379 }
380
381 /**
382 * Add the specified interface description to the set of interfaces this class
383 * description realizes. Return <code>true</code> if the set of interfaces this
384 * class description realizes changed as a result of this call.
385 *
386 * @param realizes interface description to add, must not be null
387 * @return <code>true</code> if the set of interfaces this class description realizes
388 * changed as a result of this call
389 */
390 public boolean addRealizes(final InterfaceDescription realizes)
391 {
392 if (realizes == null)
393 {
394 throw new IllegalArgumentException("realizes must not be null");
395 }
396 boolean rv = this.realizes.add(realizes);
397
398 if (rv)
399 {
400 for (Attribute a : realizes.getAttributes())
401 {
402 addAttribute(a);
403 }
404 for (Association a : realizes.getAssociations())
405 {
406 addAssociation(a);
407 }
408 }
409 return rv;
410 }
411
412 /**
413 * Add the specified interface description to the set of interfaces this class
414 * description realizes. Return <code>true</code> if the set of interfaces this
415 * class description realizes changed as a result of this call.
416 *
417 * @param realizes interface description to add, must not be null
418 * @return <code>true</code> if the set of interfaces this class description realizes
419 * changed as a result of this call
420 */
421 public boolean realizes(final InterfaceDescription realizes)
422 {
423 return addRealizes(realizes);
424 }
425
426 /**
427 * Return an unmodifiable set of attributes for this class description.
428 *
429 * @return an unmodifiable set of attributes for this class description
430 */
431 public Set<Attribute> getAttributes()
432 {
433 return Collections.unmodifiableSet(attributes);
434 }
435
436 /**
437 * Add the specified attribute to the set of attributes
438 * for this class description. Return <code>true</code> if the set
439 * of attributes changed as a result of this call.
440 *
441 * @param attribute attribute to add, must not be null
442 * @return <code>true</code> if the set of attributes
443 * changed as a result of this call
444 */
445 public boolean addAttribute(final Attribute attribute)
446 {
447 if (attribute == null)
448 {
449 throw new IllegalArgumentException("attribute must not be null");
450 }
451 return attributes.add(attribute);
452 }
453
454 /**
455 * Add the specified attribute to the set of attributes
456 * for this class description. Return <code>true</code> if the set
457 * of attributes changed as a result of this call.
458 *
459 * @param attribute attribute to add, must not be null
460 * @return <code>true</code> if the set of attributes
461 * changed as a result of this call
462 */
463 public boolean attribute(final Attribute attribute)
464 {
465 return addAttribute(attribute);
466 }
467
468 /**
469 * Add a new attribute to the set of attributes for this
470 * class description with the specified name, role name,
471 * and cardinality. The cardinality must be one of <b>Cardinality.ZeroToOne</b>
472 * or <b>Cardinality.StrictlyOne</b>. Return <code>true</code> if
473 * the set of attributes changed as a result of this call.
474 *
475 * @param name attribute name
476 * @param roleName role name
477 * @param cardinality cardinality, must not be null and must be
478 * one of <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>
479 * @return <code>true</code> if the set of attributes
480 * changed as a result of this call
481 */
482 public boolean attribute(final String name, final String roleName, final Cardinality cardinality)
483 {
484 Attribute a = new Attribute(name, roleName, cardinality);
485 return addAttribute(a);
486 }
487
488 /**
489 * Add a new attribute to the set of attributes for this
490 * class description with the specified name, role name,
491 * cardinality, and bound flag. The cardinality must be one of <b>Cardinality.ZeroToOne</b>
492 * or <b>Cardinality.StrictlyOne</b>. Return <code>true</code> if
493 * the set of attributes changed as a result of this call.
494 *
495 * @param name attribute name
496 * @param roleName role name
497 * @param cardinality cardinality, must not be null and must be
498 * one of <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>
499 * @param bound true if the attribute is to be a "bound" attribute
500 * @return <code>true</code> if the set of attributes
501 * changed as a result of this call
502 */
503 public boolean attribute(final String name, final String roleName,
504 final Cardinality cardinality, final boolean bound)
505 {
506 Attribute a = new Attribute(name, roleName, cardinality, bound);
507 return addAttribute(a);
508 }
509
510 /**
511 * Add a new attribute to the set of attributes for this
512 * class description with the specified parameters.
513 * Return <code>true</code> if the set of attributes changed as
514 * a result of this call.
515 *
516 * @param name attribute name
517 * @param roleName role name
518 * @param cardinality cardinality, must not be null
519 * @param indexed true if the collection should be indexed
520 * @param unique true if the collection should not allow duplicate elements
521 * @param ordered true if the collection should iterate over elements in <i>insertion-order</i>
522 * @param sorted true if the collection should iterate over elements in ascending element order,
523 * sorted according to the <i>natural ordering</i> of its elements (see Comparable), or by a Comparator
524 * provided at creation time
525 * @return <code>true</code> if the set of attributes
526 * changed as a result of this call
527 */
528 public boolean attribute(final String name, final String roleName, final Cardinality cardinality,
529 final boolean indexed, final boolean unique, final boolean ordered, final boolean sorted)
530 {
531 Attribute a = new Attribute(name, roleName, cardinality, indexed, unique, ordered, sorted);
532 return addAttribute(a);
533 }
534
535 /**
536 * Add a new attribute to the set of attributes for this
537 * class description with the specified parameters.
538 * Return <code>true</code> if the set of attributes changed as
539 * a result of this call.
540 *
541 * @param name attribute name
542 * @param roleName role name
543 * @param cardinality cardinality, must not be null
544 * @param bound true if the attribute is to be a "bound" attribute
545 * @param indexed true if the collection should be indexed
546 * @param unique true if the collection should not allow duplicate elements
547 * @param ordered true if the collection should iterate over elements in <i>insertion-order</i>
548 * @param sorted true if the collection should iterate over elements in ascending element order,
549 * sorted according to the <i>natural ordering</i> of its elements (see Comparable), or by a Comparator
550 * provided at creation time
551 * @return <code>true</code> if the set of attributes
552 * changed as a result of this call
553 */
554 public boolean attribute(final String name, final String roleName, final Cardinality cardinality,
555 final boolean bound,
556 final boolean indexed, final boolean unique, final boolean ordered, final boolean sorted)
557 {
558 Attribute a = new Attribute(name, roleName, cardinality, bound, indexed, unique, ordered, sorted);
559 return addAttribute(a);
560 }
561
562 /**
563 * Return an unmodifiable set of associations for this class description.
564 *
565 * @return an unmodifiable set of associations for this class description
566 */
567 public Set<Association> getAssociations()
568 {
569 return Collections.unmodifiableSet(associations);
570 }
571
572 /**
573 * Add the specified association to the set of associations
574 * for this class description. Return <code>true</code> if the set
575 * of associations changed as a result of this call.
576 *
577 * @param association association to add, must not be null
578 * @return <code>true</code> if the set of associations
579 * changed as a result of this call
580 */
581 public boolean addAssociation(final Association association)
582 {
583 if (association == null)
584 {
585 throw new IllegalArgumentException("association must not be null");
586 }
587 return associations.add(association);
588 }
589
590 /**
591 * Add the specified association to the set of associations
592 * for this class description. Return <code>true</code> if the set
593 * of associations changed as a result of this call.
594 *
595 * @param association association to add, must not be null
596 * @return <code>true</code> if the set of associations
597 * changed as a result of this call
598 */
599 public boolean associate(final Association association)
600 {
601 return addAssociation(association);
602 }
603
604 /**
605 * Add a new association to the set of associations for this
606 * class description to the specified class with the
607 * specified cardinality. The assocation's role name will be
608 * the same as the class' name. The cardinality must be one of
609 * <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>.
610 * Return <code>true</code> if the set of associations changed as a result of
611 * this call.
612 *
613 * @param cd class description, must not be null
614 * @param cardinality cardinality, must not be null and must be
615 * one of <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>
616 * @return <code>true</code> if the set of associations
617 * changed as a result of this call
618 */
619 public boolean associate(final ClassDescription cd, final Cardinality cardinality)
620 {
621 Association a = new Association(cd, cd.getUpper(), cardinality);
622 return addAssociation(a);
623 }
624
625 /**
626 * Add a new association to the set of associations for this
627 * class description to the specified class with the
628 * specified cardinality and bound flag. The assocation's role name will be
629 * the same as the class' name. The cardinality must be one of
630 * <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>.
631 * Return <code>true</code> if the set of associations changed as a result of
632 * this call.
633 *
634 * @param cd class description, must not be null
635 * @param cardinality cardinality, must not be null and must be
636 * one of <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>
637 * @param bound true if the association is to be a "bound" association
638 * @return <code>true</code> if the set of associations
639 * changed as a result of this call
640 */
641 public boolean associate(final ClassDescription cd, final Cardinality cardinality, final boolean bound)
642 {
643 Association a = new Association(cd, cd.getUpper(), cardinality, bound);
644 return addAssociation(a);
645 }
646
647 /**
648 * Add a new association to the set of attributes for this
649 * class description to the specified class with the
650 * specified role name and cardinality. The cardinality must be one of
651 * <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>.
652 * Return <code>true</code> if the set of associations changed as a result of
653 * this call.
654 *
655 * @param cd class description, must not be null
656 * @param roleName role name
657 * @param cardinality cardinality, must not be null and must be
658 * one of <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>
659 * @return <code>true</code> if the set of associations
660 * changed as a result of this call
661 */
662 public boolean associate(final ClassDescription cd, final String roleName, final Cardinality cardinality)
663 {
664 Association a = new Association(cd, roleName, cardinality);
665 return addAssociation(a);
666 }
667
668 /**
669 * Add a new association to the set of attributes for this
670 * class description to the specified class with the
671 * specified role name, cardinality, and bound flag. The cardinality must be one of
672 * <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>.
673 * Return <code>true</code> if the set of associations changed as a result of
674 * this call.
675 *
676 * @param cd class description, must not be null
677 * @param roleName role name
678 * @param cardinality cardinality, must not be null and must be
679 * one of <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>
680 * @param bound true if the association is to be a "bound" association
681 * @return <code>true</code> if the set of associations
682 * changed as a result of this call
683 */
684 public boolean associate(final ClassDescription cd, final String roleName,
685 final Cardinality cardinality, final boolean bound)
686 {
687 Association a = new Association(cd, roleName, cardinality, bound);
688 return addAssociation(a);
689 }
690
691 /**
692 * Add a new association to the set of associations for this
693 * class description to the specified class with the specified
694 * parameters. The association's role name will be the same as
695 * the class' name.
696 *
697 * @param cd class description, must not be null
698 * @param cardinality cardinality, must not be null
699 * @param indexed true if the collection should be indexed
700 * @param unique true if the collection should not allow duplicate elements
701 * @param ordered true if the collection should iterate over elements in <i>insertion-order</i>
702 * @param sorted true if the collection should iterate over elements in ascending element order,
703 * sorted according to the <i>natural ordering</i> of its elements (see Comparable), or by a Comparator
704 * provided at creation time
705 * @return <code>true</code> if the set of associations
706 * changed as a result of this call
707 */
708 public boolean associate(final ClassDescription cd, final Cardinality cardinality,
709 final boolean indexed, final boolean unique, final boolean ordered, final boolean sorted)
710 {
711 Association a = new Association(cd, cd.getUpper(), cardinality, indexed, unique, ordered, sorted);
712 return addAssociation(a);
713 }
714
715 /**
716 * Add a new association to the set of associations for this
717 * class description to the specified class with the specified
718 * parameters. The association's role name will be the same as
719 * the class' name.
720 *
721 * @param cd class description, must not be null
722 * @param cardinality cardinality, must not be null
723 * @param bound true if the assocation is to be a "bound" association
724 * @param indexed true if the collection should be indexed
725 * @param unique true if the collection should not allow duplicate elements
726 * @param ordered true if the collection should iterate over elements in <i>insertion-order</i>
727 * @param sorted true if the collection should iterate over elements in ascending element order,
728 * sorted according to the <i>natural ordering</i> of its elements (see Comparable), or by a Comparator
729 * provided at creation time
730 * @return <code>true</code> if the set of associations
731 * changed as a result of this call
732 */
733 public boolean associate(final ClassDescription cd, final Cardinality cardinality, final boolean bound,
734 final boolean indexed, final boolean unique, final boolean ordered, final boolean sorted)
735 {
736 Association a = new Association(cd, cd.getUpper(), cardinality, bound, indexed, unique, ordered, sorted);
737 return addAssociation(a);
738 }
739
740 /**
741 * Add a new association to the set of associations for this
742 * class description to the specified class with the specified
743 * parameters.
744 *
745 * @param cd class description, must not be null
746 * @param roleName role name
747 * @param cardinality cardinality, must not be null
748 * @param indexed true if the collection should be indexed
749 * @param unique true if the collection should not allow duplicate elements
750 * @param ordered true if the collection should iterate over elements in <i>insertion-order</i>
751 * @param sorted true if the collection should iterate over elements in ascending element order,
752 * sorted according to the <i>natural ordering</i> of its elements (see Comparable), or by a Comparator
753 * provided at creation time
754 * @return <code>true</code> if the set of associations
755 * changed as a result of this call
756 */
757 public boolean associate(final ClassDescription cd, final String roleName, final Cardinality cardinality,
758 final boolean indexed, final boolean unique, final boolean ordered, final boolean sorted)
759 {
760 Association a = new Association(cd, roleName, cardinality, indexed, unique, ordered, sorted);
761 return addAssociation(a);
762 }
763
764 /**
765 * Add a new association to the set of associations for this
766 * class description to the specified class with the specified
767 * parameters.
768 *
769 * @param cd class description, must not be null
770 * @param roleName role name
771 * @param cardinality cardinality, must not be null
772 * @param bound true if the association is to be a "bound" association
773 * @param indexed true if the collection should be indexed
774 * @param unique true if the collection should not allow duplicate elements
775 * @param ordered true if the collection should iterate over elements in <i>insertion-order</i>
776 * @param sorted true if the collection should iterate over elements in ascending element order,
777 * sorted according to the <i>natural ordering</i> of its elements (see Comparable), or by a Comparator
778 * provided at creation time
779 * @return <code>true</code> if the set of associations
780 * changed as a result of this call
781 */
782 public boolean associate(final ClassDescription cd, final String roleName, final Cardinality cardinality,
783 final boolean bound,
784 final boolean indexed, final boolean unique, final boolean ordered, final boolean sorted)
785 {
786 Association a = new Association(cd, roleName, cardinality, bound, indexed, unique, ordered, sorted);
787 return addAssociation(a);
788 }
789
790 /**
791 * Add a new association to the set of associations for this
792 * class description to the specified interface with the
793 * specified cardinality. The assocation's role name will be
794 * the same as the interface's name. The cardinality must be one of
795 * <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>.
796 * Return <code>true</code> if the set of associations changed as a result of
797 * this call.
798 *
799 * @param id interface description, must not be null
800 * @param cardinality cardinality, must not be null and must be
801 * one of <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>
802 * @return <code>true</code> if the set of associations
803 * changed as a result of this call
804 */
805 public boolean associate(final InterfaceDescription id, final Cardinality cardinality)
806 {
807 Association a = new Association(id, id.getUpper(), cardinality);
808 return addAssociation(a);
809 }
810
811 /**
812 * Add a new association to the set of associations for this
813 * class description to the specified interface with the
814 * specified cardinality and bound flag. The assocation's role name will be
815 * the same as the interface's name. The cardinality must be one of
816 * <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>.
817 * Return <code>true</code> if the set of associations changed as a result of
818 * this call.
819 *
820 * @param id interface description, must not be null
821 * @param cardinality cardinality, must not be null and must be
822 * one of <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>
823 * @param bound true if the assocation is to be a "bound" association
824 * @return <code>true</code> if the set of associations
825 * changed as a result of this call
826 */
827 public boolean associate(final InterfaceDescription id, final Cardinality cardinality, final boolean bound)
828 {
829 Association a = new Association(id, id.getUpper(), cardinality, bound);
830 return addAssociation(a);
831 }
832
833 /**
834 * Add a new association to the set of attributes for this
835 * class description to the specified interface with the
836 * specified role name and cardinality. The cardinality must be one of
837 * <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>.
838 * Return <code>true</code> if the set of associations changed as a result of
839 * this call.
840 *
841 * @param id interface description, must not be null
842 * @param roleName role name
843 * @param cardinality cardinality, must not be null and must be
844 * one of <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>
845 * @return <code>true</code> if the set of associations
846 * changed as a result of this call
847 */
848 public boolean associate(final InterfaceDescription id, final String roleName, final Cardinality cardinality)
849 {
850 Association a = new Association(id, roleName, cardinality);
851 return addAssociation(a);
852 }
853
854 /**
855 * Add a new association to the set of attributes for this
856 * class description to the specified interface with the
857 * specified role name, cardinality, and bound flag. The cardinality must be one of
858 * <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>.
859 * Return <code>true</code> if the set of associations changed as a result of
860 * this call.
861 *
862 * @param id interface description, must not be null
863 * @param roleName role name
864 * @param cardinality cardinality, must not be null and must be
865 * one of <b>Cardinality.ZeroToOne</b> or <b>Cardinality.StrictlyOne</b>
866 * @param bound true if the association is to be a "bound" association
867 * @return <code>true</code> if the set of associations
868 * changed as a result of this call
869 */
870 public boolean associate(final InterfaceDescription id, final String roleName,
871 final Cardinality cardinality, final boolean bound)
872 {
873 Association a = new Association(id, roleName, cardinality, bound);
874 return addAssociation(a);
875 }
876
877 /**
878 * Add a new association to the set of associations for this
879 * class description to the specified interface with the specified
880 * parameters. The association's role name will be the same as
881 * the interface's name.
882 *
883 * @param id interface description, must not be null
884 * @param cardinality cardinality, must not be null
885 * @param indexed true if the collection should be indexed
886 * @param unique true if the collection should not allow duplicate elements
887 * @param ordered true if the collection should iterate over elements in <i>insertion-order</i>
888 * @param sorted true if the collection should iterate over elements in ascending element order,
889 * sorted according to the <i>natural ordering</i> of its elements (see Comparable), or by a Comparator
890 * provided at creation time
891 * @return <code>true</code> if the set of associations
892 * changed as a result of this call
893 */
894 public boolean associate(final InterfaceDescription id, final Cardinality cardinality,
895 final boolean indexed, final boolean unique, final boolean ordered, final boolean sorted)
896 {
897 Association a = new Association(id, id.getUpper(), cardinality, indexed, unique, ordered, sorted);
898 return addAssociation(a);
899 }
900
901 /**
902 * Add a new association to the set of associations for this
903 * class description to the specified interface with the specified
904 * parameters. The association's role name will be the same as
905 * the interface's name.
906 *
907 * @param id interface description, must not be null
908 * @param cardinality cardinality, must not be null
909 * @param bound true if the association is to be a "bound" association
910 * @param indexed true if the collection should be indexed
911 * @param unique true if the collection should not allow duplicate elements
912 * @param ordered true if the collection should iterate over elements in <i>insertion-order</i>
913 * @param sorted true if the collection should iterate over elements in ascending element order,
914 * sorted according to the <i>natural ordering</i> of its elements (see Comparable), or by a Comparator
915 * provided at creation time
916 * @return <code>true</code> if the set of associations
917 * changed as a result of this call
918 */
919 public boolean associate(final InterfaceDescription id, final Cardinality cardinality, final boolean bound,
920 final boolean indexed, final boolean unique, final boolean ordered, final boolean sorted)
921 {
922 Association a = new Association(id, id.getUpper(), cardinality, bound, indexed, unique, ordered, sorted);
923 return addAssociation(a);
924 }
925
926 /**
927 * Add a new association to the set of associations for this
928 * class description to the specified interface with the specified
929 * parameters.
930 *
931 * @param id interface description, must not be null
932 * @param roleName role name
933 * @param cardinality cardinality, must not be null
934 * @param indexed true if the collection should be indexed
935 * @param unique true if the collection should not allow duplicate elements
936 * @param ordered true if the collection should iterate over elements in <i>insertion-order</i>
937 * @param sorted true if the collection should iterate over elements in ascending element order,
938 * sorted according to the <i>natural ordering</i> of its elements (see Comparable), or by a Comparator
939 * provided at creation time
940 * @return <code>true</code> if the set of associations
941 * changed as a result of this call
942 */
943 public boolean associate(final InterfaceDescription id, final String roleName, final Cardinality cardinality,
944 final boolean indexed, final boolean unique, final boolean ordered, final boolean sorted)
945 {
946 Association a = new Association(id, roleName, cardinality, indexed, unique, ordered, sorted);
947 return addAssociation(a);
948 }
949
950 /**
951 * Add a new association to the set of associations for this
952 * class description to the specified interface with the specified
953 * parameters.
954 *
955 * @param id interface description, must not be null
956 * @param roleName role name
957 * @param cardinality cardinality, must not be null
958 * @param bound true if the association is to be a "bound" association
959 * @param indexed true if the collection should be indexed
960 * @param unique true if the collection should not allow duplicate elements
961 * @param ordered true if the collection should iterate over elements in <i>insertion-order</i>
962 * @param sorted true if the collection should iterate over elements in ascending element order,
963 * sorted according to the <i>natural ordering</i> of its elements (see Comparable), or by a Comparator
964 * provided at creation time
965 * @return <code>true</code> if the set of associations
966 * changed as a result of this call
967 */
968 public boolean associate(final InterfaceDescription id, final String roleName, final Cardinality cardinality,
969 final boolean bound,
970 final boolean indexed, final boolean unique, final boolean ordered, final boolean sorted)
971 {
972 Association a = new Association(id, roleName, cardinality, bound, indexed, unique, ordered, sorted);
973 return addAssociation(a);
974 }
975 }