001// license-header java merge-point 002// 003// Attention: generated code (by MetafacadeLogic.vsl) - do not modify! 004// 005package org.andromda.metafacades.uml14; 006 007import java.util.Collection; 008import java.util.List; 009import org.andromda.core.metafacade.ModelValidationMessage; 010import org.andromda.metafacades.uml.EventFacade; 011import org.andromda.metafacades.uml.StateFacade; 012import org.apache.log4j.Logger; 013import org.omg.uml.behavioralelements.statemachines.State; 014 015/** 016 * Models a situation during which some (usually implicit) invariant condition holds. The states of 017 * protocol state machines are exposed to the users of their context classifiers. A protocol state 018 * represents an exposed stable situation of its context classifier: when an instance of the 019 * classifier is not processing any operation, users of this instance can always know its state 020 * configuration. 021 * MetafacadeLogic for StateFacade 022 * 023 * @see StateFacade 024 */ 025public abstract class StateFacadeLogic 026 extends StateVertexFacadeLogicImpl 027 implements StateFacade 028{ 029 /** 030 * The underlying UML object 031 * @see State 032 */ 033 protected State metaObject; 034 035 /** Create Metafacade implementation instance using the MetafacadeFactory from the context 036 * @param metaObjectIn 037 * @param context 038 */ 039 protected StateFacadeLogic(State metaObjectIn, String context) 040 { 041 super(metaObjectIn, getContext(context)); 042 this.metaObject = metaObjectIn; 043 } 044 045 /** 046 * The logger instance. 047 */ 048 private static final Logger logger = Logger.getLogger(StateFacadeLogic.class); 049 050 /** 051 * Gets the context for this metafacade logic instance. 052 * @param context String. Set to StateFacade if null 053 * @return context String 054 */ 055 private static String getContext(String context) 056 { 057 if (context == null) 058 { 059 context = "org.andromda.metafacades.uml.StateFacade"; 060 } 061 return context; 062 } 063 064 /** Reset context only for non-root metafacades 065 * @param context 066 */ 067 @Override 068 public void resetMetafacadeContext(String context) 069 { 070 if (!this.contextRoot) // reset context only for non-root metafacades 071 { 072 context = getContext(context); // to have same value as in original constructor call 073 setMetafacadeContext (context); 074 } 075 } 076 077 /** 078 * @return boolean true always 079 * @see StateFacade 080 */ 081 public boolean isStateFacadeMetaType() 082 { 083 return true; 084 } 085 086 // ------------- associations ------------------ 087 088 /** 089 * If this event is located on an action state, this will represent that state. 090 * @return (Collection<EventFacade>)handleGetDeferrableEvents() 091 */ 092 public final Collection<EventFacade> getDeferrableEvents() 093 { 094 Collection<EventFacade> getDeferrableEvents1r = null; 095 // state has no pre constraints 096 Collection result = handleGetDeferrableEvents(); 097 List shieldedResult = this.shieldedElements(result); 098 try 099 { 100 getDeferrableEvents1r = (Collection<EventFacade>)shieldedResult; 101 } 102 catch (ClassCastException ex) 103 { 104 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 105 StateFacadeLogic.logger.warn("incorrect metafacade cast for StateFacadeLogic.getDeferrableEvents Collection<EventFacade> " + result + ": " + shieldedResult); 106 } 107 // state has no post constraints 108 return getDeferrableEvents1r; 109 } 110 111 /** 112 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 113 * @return Collection 114 */ 115 protected abstract Collection handleGetDeferrableEvents(); 116 117 /** 118 * @param validationMessages Collection<ModelValidationMessage> 119 * @see StateVertexFacadeLogicImpl#validateInvariants(Collection validationMessages) 120 */ 121 @Override 122 public void validateInvariants(Collection<ModelValidationMessage> validationMessages) 123 { 124 super.validateInvariants(validationMessages); 125 } 126}