View Javadoc
1   package org.andromda.metafacades.uml14;
2   
3   import java.util.Collection;
4   import java.util.Iterator;
5   import java.util.TreeSet;
6   import org.andromda.metafacades.uml.GeneralizableElementFacade;
7   import org.andromda.metafacades.uml.StereotypeFacade;
8   
9   /**
10   * MetafacadeLogic implementation for org.andromda.metafacades.uml.ValueObject.
11   *
12   * @see org.andromda.metafacades.uml.ValueObject
13   * @author Bob Fields
14   */
15  public class ValueObjectLogicImpl
16          extends ValueObjectLogic
17  {
18      private static final long serialVersionUID = 6729122952696837826L;
19      // ---------------- constructor -------------------------------
20  
21      /**
22       * @param metaObject
23       * @param context
24       */
25      public ValueObjectLogicImpl(Object metaObject, String context)
26      {
27          super(metaObject, context);
28      }
29  
30      /**
31       * @return specializations
32       * @see org.andromda.metafacades.uml.ValueObject#getTypeSpecializations()
33       */
34      @Override
35      protected Collection<ValueObjectLogic> handleGetTypeSpecializations()
36      {
37          StringBuilder stereotypes = new StringBuilder();
38          for (final Iterator<StereotypeFacade> iterator = this.getStereotypes().iterator(); iterator.hasNext();)
39          {
40              stereotypes.append(iterator.next().getName()).append(',');
41          }
42          return this.handleGetTypeSpecializations(stereotypes.toString());
43      }
44  
45      /**
46       * @param stereotypes
47       * @return specializations
48       */
49      protected Collection<ValueObjectLogic> handleGetTypeSpecializations(String stereotypes)
50      {
51          Collection<ValueObjectLogic> specializations = new TreeSet<ValueObjectLogic>();
52          String[] stereotypeList = stereotypes.split(",", -1);
53          for (final Iterator<GeneralizableElementFacade> iterator = this.getAllSpecializations().iterator(); iterator.hasNext();)
54          {
55              final GeneralizableElementFacade classifier = iterator.next();
56              if (classifier instanceof ValueObjectLogic)
57              {
58                  for (int i=0; i<stereotypeList.length; i++)
59                  {
60                      if (classifier.hasStereotype(stereotypeList[i]) && !specializations.contains(classifier))
61                      {
62                          specializations.add((ValueObjectLogic) classifier);
63                      }
64                  }
65              }
66          }
67          return specializations;
68      }
69  }