View Javadoc
1   package org.andromda.metafacades.uml14;
2   
3   import java.lang.reflect.Method;
4   import java.util.Collections;
5   import java.util.List;
6   import org.andromda.metafacades.uml.FrontEndAction;
7   import org.andromda.metafacades.uml.FrontEndForward;
8   import org.andromda.metafacades.uml.TransitionFacade;
9   
10  /**
11   * MetafacadeLogic implementation for org.andromda.metafacades.uml.FrontEndEvent.
12   *
13   * @see org.andromda.metafacades.uml.FrontEndEvent
14   * @author Bob Fields
15   */
16  public class FrontEndEventLogicImpl
17      extends FrontEndEventLogic
18  {
19      private static final long serialVersionUID = -7746762732086766084L;
20  
21      /**
22       * @param metaObject
23       * @param context
24       */
25      public FrontEndEventLogicImpl (Object metaObject, String context)
26      {
27          super (metaObject, context);
28      }
29  
30      /**
31       * @see org.andromda.metafacades.uml.FrontEndEvent#isContainedInFrontEndUseCase()
32       */
33      @Override
34      protected boolean handleIsContainedInFrontEndUseCase()
35      {
36          return this.getTransition() instanceof FrontEndForward;
37      }
38  
39      /**
40       * @see org.andromda.metafacades.uml.FrontEndEvent#getControllerCall()
41       */
42      @Override
43      protected Object handleGetControllerCall()
44      {
45          // - hack until a solution is found to workaround the JMI multiple inheritance (through interfaces)
46          try
47          {
48              final Method method = metaObject.getClass().getMethod("getOperation", (Class[])null);
49              return method.invoke(metaObject, (Object[])null);
50          }
51          catch (Exception ex)
52          {
53              return null;
54          }
55      }
56  
57      /**
58       * @see org.andromda.metafacades.uml.FrontEndEvent#getAction()
59       */
60      @Override
61      protected FrontEndAction handleGetAction()
62      {
63          FrontEndAction action = null;
64          TransitionFacade transition = getTransition();
65          if (transition instanceof FrontEndAction)
66          {
67              action = (FrontEndAction)transition;
68          }
69          return action;
70      }
71  
72      /**
73       * @see org.andromda.metafacades.uml.FrontEndEvent#getControllerCalls()
74       */
75      @Override
76      protected List handleGetControllerCalls()
77      {
78          Object controllerCall = this.getControllerCall();
79          return controllerCall == null ? Collections.emptyList() : Collections.singletonList(controllerCall);
80      }
81  
82  }