1 package org.andromda.metafacades.uml14;
2
3 import java.util.ArrayList;
4 import java.util.Collection;
5 import org.andromda.metafacades.uml.ClassifierFacade;
6 import org.andromda.metafacades.uml.ModelElementFacade;
7 import org.andromda.metafacades.uml.UMLMetafacadeProperties;
8 import org.andromda.utils.StringUtilsHelper;
9 import org.apache.commons.lang.StringUtils;
10 import org.apache.commons.lang.SystemUtils;
11 import org.omg.uml.foundation.core.Comment;
12 import org.omg.uml.foundation.core.ModelElement;
13 import org.omg.uml.foundation.core.TemplateParameter;
14
15
16
17
18
19
20
21 public class TemplateParameterFacadeLogicImpl
22 extends TemplateParameterFacadeLogic
23 {
24 private static final long serialVersionUID = 34L;
25
26
27
28
29 public TemplateParameterFacadeLogicImpl (TemplateParameter metaObject, String context)
30 {
31 super (metaObject, context);
32 }
33
34
35
36
37 @Override
38 protected ModelElement handleGetParameter()
39 {
40 return metaObject.getParameter();
41 }
42
43
44
45
46 @Override
47 protected ModelElement handleGetDefaultElement()
48 {
49 return metaObject.getDefaultElement();
50 }
51
52 @Override
53 protected ClassifierFacade handleGetType()
54 {
55 final ParameterFacadeLogicImpl parameter = (ParameterFacadeLogicImpl)this.getParameter();
56 return parameter.getType();
57 }
58
59 @Override
60 protected String handleGetGetterSetterTypeName()
61 {
62 if (this.handleGetType()==null)
63 {
64 return "";
65 }
66 else
67 {
68
69 return this.getType().getFullyQualifiedName();
70 }
71 }
72
73 @Override
74 protected String handleGetName()
75 {
76 return metaObject.getParameter().getName();
77 }
78
79 @Override
80 protected String handleGetFullyQualifiedName()
81 {
82 final ModelElementFacade parameter = this.getParameter();
83 return parameter.getFullyQualifiedName();
84 }
85
86 @Override
87 protected String handleGetGetterName()
88 {
89 return "get" + StringUtils.capitalize(this.getName());
90 }
91
92 @Override
93 protected String handleGetSetterName()
94 {
95 return "set" + StringUtils.capitalize(this.getName());
96 }
97
98
99
100
101
102 @Override
103 protected Collection<ClassifierFacade> handleGetConstrainingClassifiers()
104 {
105 return new ArrayList<ClassifierFacade>();
106 }
107
108 @Override
109 protected ModelElementFacade handleGetOwner()
110 {
111 return (ModelElementFacade) this.shieldedElement(this.metaObject.getTemplate().getNamespace());
112 }
113
114 @Override
115 protected String handleGetDocumentation(String indent)
116 {
117 return getDocumentation(
118 indent,
119 80 - indent.length());
120 }
121
122 @Override
123 protected String handleGetDocumentation(String indent, int lineLength)
124 {
125 return getDocumentation(
126 indent,
127 lineLength,
128 true);
129 }
130
131
132
133
134
135 @Override
136 protected String handleGetDocumentation(String indent, int lineLength, boolean htmlStyle)
137 {
138 final StringBuilder documentation = new StringBuilder();
139
140 if (lineLength < 1)
141 {
142 lineLength = Integer.MAX_VALUE;
143 }
144
145 final Collection<Comment> comments = this.metaObject.getParameter().getComment();
146 if (comments != null && !comments.isEmpty())
147 {
148 for (Comment comment : comments)
149 {
150 String commentString = StringUtils.trimToEmpty(comment.getBody());
151
152
153 if (StringUtils.isBlank(commentString))
154 {
155 commentString = StringUtils.trimToEmpty(comment.getName());
156 }
157 documentation.append(StringUtils.trimToEmpty(commentString));
158 documentation.append(SystemUtils.LINE_SEPARATOR);
159 }
160 }
161
162
163 if (StringUtils.isEmpty(documentation.toString()))
164 {
165 if (Boolean.valueOf((String)this.getConfiguredProperty(UMLMetafacadeProperties.TODO_FOR_MISSING_DOCUMENTATION)))
166 {
167 String todoTag = (String)this.getConfiguredProperty(UMLMetafacadeProperties.TODO_TAG);
168 documentation.append(todoTag).append(": Model Documentation for " + this.getFullyQualifiedName());
169 }
170 }
171
172
173 String rtn = StringUtilsHelper.format(
174 StringUtils.trimToEmpty(documentation.toString()),
175 indent,
176 lineLength,
177 htmlStyle);
178
179 return rtn;
180 }
181
182
183
184 @Override
185 public String getValidationName()
186 {
187 return metaObject.getParameter().getName();
188 }
189
190
191
192
193 @Override
194 public ModelElement getValidationOwner()
195 {
196 return metaObject.getTemplate();
197 }
198 }