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.MetafacadeBase; 010import org.andromda.core.metafacade.ModelValidationMessage; 011import org.andromda.metafacades.uml.AssociationEndFacade; 012import org.andromda.metafacades.uml.InstanceFacade; 013import org.andromda.metafacades.uml.LinkEndFacade; 014import org.andromda.metafacades.uml.LinkFacade; 015import org.apache.log4j.Logger; 016import org.omg.uml.behavioralelements.commonbehavior.LinkEnd; 017 018/** 019 * Can be an AttributeLinkImpl or LinkEndImpl. A representation of the model object 'Slot'. A slot 020 * specifies that an entity modeled by an instance specification has a value or values for a 021 * specific structural feature. 022 * MetafacadeLogic for LinkEndFacade 023 * 024 * @see LinkEndFacade 025 */ 026public abstract class LinkEndFacadeLogic 027 extends ModelElementFacadeLogicImpl 028 implements LinkEndFacade 029{ 030 /** 031 * The underlying UML object 032 * @see LinkEnd 033 */ 034 protected LinkEnd metaObject; 035 036 /** Create Metafacade implementation instance using the MetafacadeFactory from the context 037 * @param metaObjectIn 038 * @param context 039 */ 040 protected LinkEndFacadeLogic(LinkEnd metaObjectIn, String context) 041 { 042 super(metaObjectIn, getContext(context)); 043 this.metaObject = metaObjectIn; 044 } 045 046 /** 047 * The logger instance. 048 */ 049 private static final Logger logger = Logger.getLogger(LinkEndFacadeLogic.class); 050 051 /** 052 * Gets the context for this metafacade logic instance. 053 * @param context String. Set to LinkEndFacade if null 054 * @return context String 055 */ 056 private static String getContext(String context) 057 { 058 if (context == null) 059 { 060 context = "org.andromda.metafacades.uml.LinkEndFacade"; 061 } 062 return context; 063 } 064 065 /** Reset context only for non-root metafacades 066 * @param context 067 */ 068 @Override 069 public void resetMetafacadeContext(String context) 070 { 071 if (!this.contextRoot) // reset context only for non-root metafacades 072 { 073 context = getContext(context); // to have same value as in original constructor call 074 setMetafacadeContext (context); 075 } 076 } 077 078 /** 079 * @return boolean true always 080 * @see LinkEndFacade 081 */ 082 public boolean isLinkEndFacadeMetaType() 083 { 084 return true; 085 } 086 087 // ------------- associations ------------------ 088 089 private LinkFacade __getLink1r; 090 private boolean __getLink1rSet = false; 091 092 /** 093 * The two links ends owned by this link. 094 * @return (LinkFacade)handleGetLink() 095 */ 096 public final LinkFacade getLink() 097 { 098 LinkFacade getLink1r = this.__getLink1r; 099 if (!this.__getLink1rSet) 100 { 101 // linkEnds has no pre constraints 102 Object result = handleGetLink(); 103 MetafacadeBase shieldedResult = this.shieldedElement(result); 104 try 105 { 106 getLink1r = (LinkFacade)shieldedResult; 107 } 108 catch (ClassCastException ex) 109 { 110 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 111 LinkEndFacadeLogic.logger.warn("incorrect metafacade cast for LinkEndFacadeLogic.getLink LinkFacade " + result + ": " + shieldedResult); 112 } 113 // linkEnds has no post constraints 114 this.__getLink1r = getLink1r; 115 if (isMetafacadePropertyCachingEnabled()) 116 { 117 this.__getLink1rSet = true; 118 } 119 } 120 return getLink1r; 121 } 122 123 /** 124 * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type 125 * @return Object 126 */ 127 protected abstract Object handleGetLink(); 128 129 private AssociationEndFacade __getAssociationEnd2r; 130 private boolean __getAssociationEnd2rSet = false; 131 132 /** 133 * Can be an AttributeLinkImpl or LinkEndImpl. A representation of the model object 'Slot'. A 134 * slot 135 * specifies that an entity modeled by an instance specification has a value or values for a 136 * specific 137 * structural feature. 138 * @return (AssociationEndFacade)handleGetAssociationEnd() 139 */ 140 public final AssociationEndFacade getAssociationEnd() 141 { 142 AssociationEndFacade getAssociationEnd2r = this.__getAssociationEnd2r; 143 if (!this.__getAssociationEnd2rSet) 144 { 145 // linkEndFacade has no pre constraints 146 Object result = handleGetAssociationEnd(); 147 MetafacadeBase shieldedResult = this.shieldedElement(result); 148 try 149 { 150 getAssociationEnd2r = (AssociationEndFacade)shieldedResult; 151 } 152 catch (ClassCastException ex) 153 { 154 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 155 LinkEndFacadeLogic.logger.warn("incorrect metafacade cast for LinkEndFacadeLogic.getAssociationEnd AssociationEndFacade " + result + ": " + shieldedResult); 156 } 157 // linkEndFacade has no post constraints 158 this.__getAssociationEnd2r = getAssociationEnd2r; 159 if (isMetafacadePropertyCachingEnabled()) 160 { 161 this.__getAssociationEnd2rSet = true; 162 } 163 } 164 return getAssociationEnd2r; 165 } 166 167 /** 168 * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type 169 * @return Object 170 */ 171 protected abstract Object handleGetAssociationEnd(); 172 173 private InstanceFacade __getInstance3r; 174 private boolean __getInstance3rSet = false; 175 176 /** 177 * Those slots that map onto association ends. 178 * @return (InstanceFacade)handleGetInstance() 179 */ 180 public final InstanceFacade getInstance() 181 { 182 InstanceFacade getInstance3r = this.__getInstance3r; 183 if (!this.__getInstance3rSet) 184 { 185 // linkEnds has no pre constraints 186 Object result = handleGetInstance(); 187 MetafacadeBase shieldedResult = this.shieldedElement(result); 188 try 189 { 190 getInstance3r = (InstanceFacade)shieldedResult; 191 } 192 catch (ClassCastException ex) 193 { 194 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 195 LinkEndFacadeLogic.logger.warn("incorrect metafacade cast for LinkEndFacadeLogic.getInstance InstanceFacade " + result + ": " + shieldedResult); 196 } 197 // linkEnds has no post constraints 198 this.__getInstance3r = getInstance3r; 199 if (isMetafacadePropertyCachingEnabled()) 200 { 201 this.__getInstance3rSet = true; 202 } 203 } 204 return getInstance3r; 205 } 206 207 /** 208 * UML Specific type is transformed by shieldedElements to AndroMDA Metafacade type 209 * @return Object 210 */ 211 protected abstract Object handleGetInstance(); 212 213 private Collection<InstanceFacade> __getInstances4r; 214 private boolean __getInstances4rSet = false; 215 216 /** 217 * Can be an AttributeLinkImpl or LinkEndImpl. A representation of the model object 'Slot'. A 218 * slot 219 * specifies that an entity modeled by an instance specification has a value or values for a 220 * specific 221 * structural feature. 222 * @return (Collection<InstanceFacade>)handleGetInstances() 223 */ 224 public final Collection<InstanceFacade> getInstances() 225 { 226 Collection<InstanceFacade> getInstances4r = this.__getInstances4r; 227 if (!this.__getInstances4rSet) 228 { 229 // linkEndFacade has no pre constraints 230 Collection result = handleGetInstances(); 231 List shieldedResult = this.shieldedElements(result); 232 try 233 { 234 getInstances4r = (Collection<InstanceFacade>)shieldedResult; 235 } 236 catch (ClassCastException ex) 237 { 238 // Bad things happen if the metafacade type mapping in metafacades.xml is wrong - Warn 239 LinkEndFacadeLogic.logger.warn("incorrect metafacade cast for LinkEndFacadeLogic.getInstances Collection<InstanceFacade> " + result + ": " + shieldedResult); 240 } 241 // linkEndFacade has no post constraints 242 this.__getInstances4r = getInstances4r; 243 if (isMetafacadePropertyCachingEnabled()) 244 { 245 this.__getInstances4rSet = true; 246 } 247 } 248 return getInstances4r; 249 } 250 251 /** 252 * UML Specific type is returned in Collection, transformed by shieldedElements to AndroMDA Metafacade type 253 * @return Collection 254 */ 255 protected abstract Collection handleGetInstances(); 256 257 /** 258 * @param validationMessages Collection<ModelValidationMessage> 259 * @see ModelElementFacadeLogicImpl#validateInvariants(Collection validationMessages) 260 */ 261 @Override 262 public void validateInvariants(Collection<ModelValidationMessage> validationMessages) 263 { 264 super.validateInvariants(validationMessages); 265 } 266}