1 package org.andromda.core.cartridge.template;
2
3 import java.util.ArrayList;
4 import java.util.Collection;
5 import java.util.LinkedHashSet;
6 import java.util.Set;
7 import org.andromda.core.common.ExceptionUtils;
8 import org.andromda.core.metafacade.MetafacadeBase;
9 import org.apache.commons.lang.StringUtils;
10
11
12
13
14
15
16
17
18
19
20 public class ModelElements
21 {
22 private String variable;
23 private final Collection<ModelElement> modelElements = new ArrayList<ModelElement>();
24
25
26
27
28
29
30
31
32
33 public String getVariable()
34 {
35 return variable;
36 }
37
38
39
40
41 public void setVariable(String variable)
42 {
43 variable = StringUtils.trimToEmpty(variable);
44 ExceptionUtils.checkEmpty("variable", variable);
45 this.variable = variable;
46 }
47
48
49
50
51
52
53 public void addModelElement(final ModelElement modelElement)
54 {
55 ExceptionUtils.checkNull("modelElement", modelElement);
56 modelElements.add(modelElement);
57 }
58
59
60
61
62
63
64 public Set<MetafacadeBase> getAllMetafacades()
65 {
66 final Set<MetafacadeBase> allMetafacades = new LinkedHashSet<MetafacadeBase>();
67 for (ModelElement modelElement : modelElements)
68 {
69 allMetafacades.addAll(modelElement.getMetafacades());
70 }
71 return allMetafacades;
72 }
73
74
75
76
77
78
79 public Collection<ModelElement> getModelElements()
80 {
81 return this.modelElements;
82 }
83
84
85
86
87
88
89 public boolean isEmpty()
90 {
91 return this.modelElements.isEmpty();
92 }
93 }