View Javadoc
1   package org.andromda.metafacades.uml14;
2   
3   import org.andromda.metafacades.uml.NameMasker;
4   import org.andromda.metafacades.uml.UMLMetafacadeProperties;
5   import org.apache.commons.lang.StringUtils;
6   import org.omg.uml.foundation.core.EnumerationLiteral;
7   
8   /**
9    * MetafacadeLogic implementation for org.andromda.metafacades.uml.EnumerationLiteralFacade.
10   *
11   * @see org.andromda.metafacades.uml.EnumerationLiteralFacade
12   * @author Bob Fields
13   */
14  public class EnumerationLiteralFacadeLogicImpl
15      extends EnumerationLiteralFacadeLogic
16  {
17      private static final long serialVersionUID = 8552041173866794442L;
18  
19      /**
20       * @param metaObject
21       * @param context
22       */
23      public EnumerationLiteralFacadeLogicImpl(
24          EnumerationLiteral metaObject,
25          String context)
26      {
27          super(metaObject, context);
28      }
29  
30      /**
31       * @see org.andromda.metafacades.uml.EnumerationLiteralFacade#getName()
32       */
33      @Override
34      protected String handleGetName()
35      {
36          return this.getName(false);
37      }
38  
39      /**
40       * @see org.andromda.metafacades.uml.EnumerationLiteralFacade#getValue()
41       */
42      @Override
43      protected String handleGetValue()
44      {
45          return this.getValue(false);
46      }
47  
48      /**
49       * @see org.andromda.metafacades.uml.EnumerationLiteralFacade#getName(boolean)
50       */
51      @Override
52      protected String handleGetName(boolean modelName)
53      {
54          String name = super.handleGetName();
55          final String mask = String.valueOf(this.getConfiguredProperty(UMLMetafacadeProperties.ENUMERATION_LITERAL_NAME_MASK));
56          if (!modelName && StringUtils.isNotBlank(mask))
57          {
58              name = NameMasker.mask(name, mask);
59          }
60          return name;
61      }
62  
63      /**
64       * @see org.andromda.metafacades.uml.EnumerationLiteralFacade#getValue(boolean)
65       */
66      @Override
67      protected String handleGetValue(boolean modelValue)
68      {
69          return StringUtils.trimToEmpty(this.getName(modelValue));
70      }
71  
72  
73      /**
74       * @see org.andromda.metafacades.uml14.EnumerationLiteralFacadeLogic#handleGetEnumerationValue()
75       */
76      protected String handleGetEnumerationValue() {
77          String value = this.getValue();
78          if (StringUtils.isEmpty(value))
79          {
80              value = "\"\"";
81          }
82          if (value.indexOf('"')<0)
83          {
84              value = '\"' + value + '\"';
85          }
86          return value;
87      }
88  }