1
2
3
4
5 package org.andromda.metafacades.uml14;
6
7 import java.util.Collection;
8 import org.andromda.core.common.Introspector;
9 import org.andromda.core.metafacade.MetafacadeBase;
10 import org.andromda.core.metafacade.ModelValidationMessage;
11 import org.andromda.metafacades.uml.ModelElementFacade;
12 import org.andromda.metafacades.uml.TemplateArgumentFacade;
13 import org.apache.log4j.Logger;
14 import org.omg.uml.foundation.core.TemplateArgument;
15
16
17
18
19
20
21
22
23 public abstract class TemplateArgumentFacadeLogic
24 extends MetafacadeBase
25 implements TemplateArgumentFacade
26 {
27
28
29
30
31 protected TemplateArgument metaObject;
32
33
34
35
36
37 protected TemplateArgumentFacadeLogic(TemplateArgument metaObjectIn, String context)
38 {
39 super(metaObjectIn, getContext(context));
40 this.metaObject = metaObjectIn;
41 }
42
43
44
45
46 private static final Logger logger = Logger.getLogger(TemplateArgumentFacadeLogic.class);
47
48
49
50
51
52
53 private static String getContext(String context)
54 {
55 if (context == null)
56 {
57 context = "org.andromda.metafacades.uml.TemplateArgumentFacade";
58 }
59 return context;
60 }
61
62
63
64
65 @Override
66 public void resetMetafacadeContext(String context)
67 {
68 if (!this.contextRoot)
69 {
70 context = getContext(context);
71 setMetafacadeContext (context);
72 }
73 }
74
75
76
77
78
79 public boolean isTemplateArgumentFacadeMetaType()
80 {
81 return true;
82 }
83
84
85
86
87
88
89
90
91
92 public final ModelElementFacade getElement()
93 {
94 ModelElementFacade getElement1r = null;
95
96 Object result = handleGetElement();
97 MetafacadeBase shieldedResult = this.shieldedElement(result);
98 try
99 {
100 getElement1r = (ModelElementFacade)shieldedResult;
101 }
102 catch (ClassCastException ex)
103 {
104
105 TemplateArgumentFacadeLogic.logger.warn("incorrect metafacade cast for TemplateArgumentFacadeLogic.getElement ModelElementFacade " + result + ": " + shieldedResult);
106 }
107
108 return getElement1r;
109 }
110
111
112
113
114
115 protected abstract Object handleGetElement();
116
117
118
119
120
121 @Override
122 public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
123 {
124 }
125
126
127
128
129 private static final String NAME_PROPERTY = "name";
130 private static final String FQNAME_PROPERTY = "fullyQualifiedName";
131
132
133
134
135 @Override
136 public String toString()
137 {
138 final StringBuilder toString = new StringBuilder(this.getClass().getName());
139 toString.append("[");
140 try
141 {
142 toString.append(Introspector.instance().getProperty(this, FQNAME_PROPERTY));
143 }
144 catch (final Throwable tryAgain)
145 {
146 try
147 {
148 toString.append(Introspector.instance().getProperty(this, NAME_PROPERTY));
149 }
150 catch (final Throwable ignore)
151 {
152
153 }
154 }
155 toString.append("]");
156 return toString.toString();
157 }
158 }