01: package org.andromda.cartridges.meta.metafacades;
02:
03: import org.andromda.cartridges.meta.MetaProfile;
04: import org.andromda.metafacades.uml.GeneralizableElementFacade;
05: import org.apache.commons.lang.ObjectUtils;
06: import org.apache.commons.lang.StringUtils;
07:
08: import java.util.Collection;
09:
10: /**
11: * MetafacadeLogic implementation for org.andromda.cartridges.meta.metafacades.MetafacadeGeneralization.
12: *
13: * @see org.andromda.cartridges.meta.metafacades.MetafacadeGeneralization
14: */
15: public class MetafacadeGeneralizationLogicImpl extends
16: MetafacadeGeneralizationLogic {
17: public MetafacadeGeneralizationLogicImpl(Object metaObject,
18: String context) {
19: super (metaObject, context);
20: }
21:
22: /**
23: * @see org.andromda.cartridges.meta.metafacades.MetafacadeGeneralization#getPrecedence()
24: */
25: protected java.lang.Integer handleGetPrecedence() {
26: Integer precedence = new Integer(999999999);
27: String value = ObjectUtils
28: .toString(this
29: .findTaggedValue(MetaProfile.TAGGEDVALUE_GENERALIZATION_PRECEDENCE));
30: if (StringUtils.isNotBlank(value)) {
31: try {
32: precedence = new Integer(value);
33: } catch (NumberFormatException ex) {
34: // ignore since we'll just take the large default.
35: }
36: }
37: return precedence;
38: }
39:
40: /**
41: * @see org.andromda.cartridges.meta.metafacades.MetafacadeGeneralization#getGetterName()
42: */
43: protected String handleGetGetterName() {
44: String name = this .getName();
45: if (StringUtils.isBlank(name)) {
46: if (this .getParent() != null) {
47: name = this .getParent().getName();
48: }
49: }
50: name = StringUtils.capitalize(name);
51: return "get" + name;
52: }
53:
54: /**
55: * @see org.andromda.cartridges.meta.metafacades.MetafacadeGeneralization#getGetterNameVisibility()
56: */
57: protected String handleGetGetterNameVisibility() {
58: String visibility = "private";
59: GeneralizableElementFacade child = this .getChild();
60: if (child != null) {
61: // if we have more than one generalization for the metafacade
62: // then we expose the super facade accessors.
63: Collection generalizations = child.getGeneralizations();
64: if ((generalizations != null)
65: && (generalizations.size() > 1)) {
66: visibility = "protected";
67: }
68: }
69: return visibility;
70: }
71:
72: /**
73: * @see org.andromda.metafacades.uml.ModelElementFacade#getName()
74: */
75: public String getName() {
76: String name = super .getName();
77: if (StringUtils.isBlank(name) && (this .getParent() != null)) {
78: name = this .getParent().getName();
79: }
80: return ObjectUtils
81: .toString(
82: this
83: .getConfiguredProperty(MetaGlobals.PROPERTY_GENERALIZATION_NAME_PATTERN))
84: .replaceAll("\\{0\\}", name);
85: }
86: }
|