1 package org.andromda.cartridges.meta.metafacades;
2
3 import java.util.Collection;
4 import org.andromda.cartridges.meta.MetaProfile;
5 import org.andromda.metafacades.uml.GeneralizableElementFacade;
6 import org.apache.commons.lang.ObjectUtils;
7 import org.apache.commons.lang.StringUtils;
8
9
10
11
12
13
14
15 public class MetafacadeGeneralizationLogicImpl
16 extends MetafacadeGeneralizationLogic
17 {
18 private static final long serialVersionUID = 34L;
19
20
21
22
23 public MetafacadeGeneralizationLogicImpl(
24 Object metaObjectIn,
25 String context)
26 {
27 super(metaObjectIn, context);
28 }
29
30
31
32
33 @Override
34 protected Integer handleGetPrecedence()
35 {
36 Integer precedence = Integer.valueOf(999999999);
37 String value =
38 ObjectUtils.toString(
39 this.findTaggedValue(MetaProfile.TAGGEDVALUE_GENERALIZATION_PRECEDENCE));
40 if (StringUtils.isNotBlank(value))
41 {
42 try
43 {
44 precedence = Integer.valueOf(value);
45 }
46 catch (NumberFormatException ex)
47 {
48
49 }
50 }
51 return precedence;
52 }
53
54
55
56
57 @Override
58 protected String handleGetGetterName()
59 {
60 String name = this.getName();
61 if (StringUtils.isBlank(name))
62 {
63 if (this.getParent() != null)
64 {
65 name = this.getParent().getName();
66 }
67 }
68 name = StringUtils.capitalize(name);
69 return "get" + name;
70 }
71
72
73
74
75 @Override
76 protected String handleGetGetterNameVisibility()
77 {
78 String visibility = "private";
79 GeneralizableElementFacade child = this.getChild();
80 if (child != null)
81 {
82
83
84 Collection<GeneralizableElementFacade> generalizations = child.getGeneralizations();
85 if ((generalizations != null) && (generalizations.size() > 1))
86 {
87 visibility = "protected";
88 }
89 }
90 return visibility;
91 }
92
93
94
95
96 @Override
97 public String getName()
98 {
99 String name = super.getName();
100 if (StringUtils.isBlank(name) && (this.getParent() != null))
101 {
102 name = this.getParent().getName();
103 }
104 return ObjectUtils.toString(
105 this.getConfiguredProperty(MetaGlobals.PROPERTY_GENERALIZATION_NAME_PATTERN))
106 .replaceAll("\\{0\\}", name);
107 }
108 }