View Javadoc
1   package org.andromda.cartridges.ejb3.metafacades;
2   
3   import java.text.MessageFormat;
4   import org.andromda.metafacades.uml.UMLProfile;
5   import org.apache.commons.lang.ObjectUtils;
6   import org.apache.commons.lang.StringUtils;
7   
8   /**
9    * MetafacadeLogic implementation for org.andromda.cartridges.ejb3.metafacades.EJB3EmbeddedValueFacade.
10   *
11   * @see EJB3EmbeddedValueFacade
12   */
13  public class EJB3EmbeddedValueFacadeLogicImpl
14      extends EJB3EmbeddedValueFacadeLogic
15  {
16      private static final long serialVersionUID = 34L;
17      /**
18       * The property which stores the pattern defining the embedded value
19       * implementation name.
20       */
21      static final String EMBEDDED_VALUE_IMPLEMENTATION_NAME_PATTERN = "embeddedValueImplementationNamePattern";
22  
23      /**
24       * @param metaObject
25       * @param context
26       */
27      public EJB3EmbeddedValueFacadeLogicImpl(final Object metaObject, final String context)
28      {
29          super(metaObject, context);
30      }
31  
32      /**
33       * @see EJB3EmbeddedValueFacade#isImmutable()
34       */
35      @Override
36      protected boolean handleIsImmutable()
37      {
38          boolean immutable = false;
39          Object value = this.findTaggedValue(UMLProfile.TAGGEDVALUE_PERSISTENCE_IMMUTABLE);
40          if (value != null)
41          {
42              immutable = Boolean.valueOf(ObjectUtils.toString(value)).booleanValue();
43          }
44          return immutable;
45      }
46  
47      /**
48       * @see EJB3EmbeddedValueFacade#getImplementationName()
49       */
50      @Override
51      protected String handleGetImplementationName()
52      {
53          return MessageFormat.format(
54                  this.getImplementationNamePattern(),
55                  StringUtils.trimToEmpty(this.getName()));
56      }
57  
58      /**
59       * Gets the value of the {@link #EMBEDDED_VALUE_IMPLEMENTATION_NAME_PATTERN}
60       *
61       * @return the embedded value name pattern.
62       */
63      private String getImplementationNamePattern()
64      {
65          return String.valueOf(this.getConfiguredProperty(EMBEDDED_VALUE_IMPLEMENTATION_NAME_PATTERN));
66      }
67  
68      /**
69       * @see EJB3EmbeddedValueFacadeLogic#handleGetFullyQualifiedImplementationName()
70       */
71      @Override
72      protected String handleGetFullyQualifiedImplementationName()
73      {
74          return EJB3MetafacadeUtils.getFullyQualifiedName(
75                  this.getPackageName(),
76                  this.getImplementationName(),
77                  null);
78      }
79  }