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