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.ModelElementFacade; 011import org.andromda.metafacades.uml.NamespaceFacade; 012import org.apache.log4j.Logger; 013import org.omg.uml.foundation.core.Classifier; 014 015/** 016 * An element in a model that contains a set of named elements that can be identified by name. 017 * MetafacadeLogic for NamespaceFacade 018 * 019 * @see NamespaceFacade 020 */ 021public abstract class NamespaceFacadeLogic 022 extends ClassifierFacadeLogicImpl 023 implements NamespaceFacade 024{ 025 /** 026 * The underlying UML object 027 * @see Object 028 */ 029 protected Object metaObject; 030 031 /** Create Metafacade implementation instance using the MetafacadeFactory from the context 032 * @param metaObjectIn 033 * @param context 034 */ 035 protected NamespaceFacadeLogic(Object metaObjectIn, String context) 036 { 037 super((Classifier)metaObjectIn, getContext(context)); 038 this.metaObject = metaObjectIn; 039 } 040 041 /** 042 * The logger instance. 043 */ 044 private static final Logger logger = Logger.getLogger(NamespaceFacadeLogic.class); 045 046 /** 047 * Gets the context for this metafacade logic instance. 048 * @param context String. Set to NamespaceFacade if null 049 * @return context String 050 */ 051 private static String getContext(String context) 052 { 053 if (context == null) 054 { 055 context = "org.andromda.metafacades.uml.NamespaceFacade"; 056 } 057 return context; 058 } 059 060 /** Reset context only for non-root metafacades 061 * @param context 062 */ 063 @Override 064 public void resetMetafacadeContext(String context) 065 { 066 if (!this.contextRoot) // reset context only for non-root metafacades 067 { 068 context = getContext(context); // to have same value as in original constructor call 069 setMetafacadeContext (context); 070 } 071 } 072 073 /** 074 * @return boolean true always 075 * @see NamespaceFacade 076 */ 077 public boolean isNamespaceFacadeMetaType() 078 { 079 return true; 080 } 081 082 // ------------- associations ------------------ 083 084 /** 085 * Gets the namespace to which this model element belongs. 086 * @return (Collection<ModelElementFacade>)handleGetOwnedElements() 087 */ 088 public final Collection<ModelElementFacade> getOwnedElements() 089 { 090 Collection<ModelElementFacade> getOwnedElements1r = null; 091 // namespace has no pre constraints 092 Collection result = handleGetOwnedElements(); 093 List shieldedResult = this.shieldedElements(result); 094 try 095 { 096 getOwnedElements1r = (Collection<ModelElementFacade>)shieldedResult; 097 } 098 catch (ClassCastException ex) 099 { 100 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 101 NamespaceFacadeLogic.logger.warn("incorrect metafacade cast for NamespaceFacadeLogic.getOwnedElements Collection<ModelElementFacade> " + result + ": " + shieldedResult); 102 } 103 // namespace has no post constraints 104 return getOwnedElements1r; 105 } 106 107 /** 108 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 109 * @return Collection 110 */ 111 protected abstract Collection handleGetOwnedElements(); 112 113 /** 114 * @param validationMessages Collection<ModelValidationMessage> 115 * @see ClassifierFacadeLogicImpl#validateInvariants(Collection validationMessages) 116 */ 117 @Override 118 public void validateInvariants(Collection<ModelValidationMessage> validationMessages) 119 { 120 super.validateInvariants(validationMessages); 121 } 122}