1 17 package org.eclipse.emf.codegen.ecore.genmodel.impl; 18 19 20 import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage; 21 import org.eclipse.emf.codegen.ecore.genmodel.GenOperation; 22 import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; 23 import org.eclipse.emf.codegen.ecore.genmodel.GenParameter; 24 import org.eclipse.emf.common.notify.Notification; 25 import org.eclipse.emf.common.notify.NotificationChain; 26 import org.eclipse.emf.ecore.EClass; 27 import org.eclipse.emf.ecore.EClassifier; 28 import org.eclipse.emf.ecore.EDataType; 29 import org.eclipse.emf.ecore.EEnum; 30 import org.eclipse.emf.ecore.EParameter; 31 import org.eclipse.emf.ecore.EStructuralFeature; 32 import org.eclipse.emf.ecore.ETypedElement; 33 import org.eclipse.emf.ecore.InternalEObject; 34 import org.eclipse.emf.ecore.impl.ENotificationImpl; 35 import org.eclipse.emf.ecore.util.EcoreUtil; 36 37 38 52 public class GenParameterImpl extends GenTypedElementImpl implements GenParameter 53 { 54 62 protected EParameter ecoreParameter = null; 63 64 69 protected GenParameterImpl() 70 { 71 super(); 72 } 73 74 79 protected EClass eStaticClass() 80 { 81 return GenModelPackage.eINSTANCE.getGenParameter(); 82 } 83 84 89 public GenOperation getGenOperation() 90 { 91 if (eContainerFeatureID != GenModelPackage.GEN_PARAMETER__GEN_OPERATION) return null; 92 return (GenOperation)eContainer; 93 } 94 95 100 public void setGenOperation(GenOperation newGenOperation) 101 { 102 if (newGenOperation != eContainer || (eContainerFeatureID != GenModelPackage.GEN_PARAMETER__GEN_OPERATION && newGenOperation != null)) 103 { 104 if (EcoreUtil.isAncestor(this, newGenOperation)) 105 throw new IllegalArgumentException ("Recursive containment not allowed for " + toString()); 106 NotificationChain msgs = null; 107 if (eContainer != null) 108 msgs = eBasicRemoveFromContainer(msgs); 109 if (newGenOperation != null) 110 msgs = ((InternalEObject)newGenOperation).eInverseAdd(this, GenModelPackage.GEN_OPERATION__GEN_PARAMETERS, GenOperation.class, msgs); 111 msgs = eBasicSetContainer((InternalEObject)newGenOperation, GenModelPackage.GEN_PARAMETER__GEN_OPERATION, msgs); 112 if (msgs != null) msgs.dispatch(); 113 } 114 else if (eNotificationRequired()) 115 eNotify(new ENotificationImpl(this, Notification.SET, GenModelPackage.GEN_PARAMETER__GEN_OPERATION, newGenOperation, newGenOperation)); 116 } 117 118 123 public EParameter getEcoreParameter() 124 { 125 if (ecoreParameter != null && ecoreParameter.eIsProxy()) 126 { 127 EParameter oldEcoreParameter = ecoreParameter; 128 ecoreParameter = (EParameter)eResolveProxy((InternalEObject)ecoreParameter); 129 if (ecoreParameter != oldEcoreParameter) 130 { 131 if (eNotificationRequired()) 132 eNotify(new ENotificationImpl(this, Notification.RESOLVE, GenModelPackage.GEN_PARAMETER__ECORE_PARAMETER, oldEcoreParameter, ecoreParameter)); 133 } 134 } 135 return ecoreParameter; 136 } 137 138 143 public EParameter basicGetEcoreParameter() 144 { 145 return ecoreParameter; 146 } 147 148 153 public void setEcoreParameter(EParameter newEcoreParameter) 154 { 155 EParameter oldEcoreParameter = ecoreParameter; 156 ecoreParameter = newEcoreParameter; 157 if (eNotificationRequired()) 158 eNotify(new ENotificationImpl(this, Notification.SET, GenModelPackage.GEN_PARAMETER__ECORE_PARAMETER, oldEcoreParameter, ecoreParameter)); 159 } 160 161 166 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) 167 { 168 if (featureID >= 0) 169 { 170 switch (eDerivedStructuralFeatureID(featureID, baseClass)) 171 { 172 case GenModelPackage.GEN_PARAMETER__GEN_OPERATION: 173 if (eContainer != null) 174 msgs = eBasicRemoveFromContainer(msgs); 175 return eBasicSetContainer(otherEnd, GenModelPackage.GEN_PARAMETER__GEN_OPERATION, msgs); 176 default: 177 return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); 178 } 179 } 180 if (eContainer != null) 181 msgs = eBasicRemoveFromContainer(msgs); 182 return eBasicSetContainer(otherEnd, featureID, msgs); 183 } 184 185 190 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) 191 { 192 if (featureID >= 0) 193 { 194 switch (eDerivedStructuralFeatureID(featureID, baseClass)) 195 { 196 case GenModelPackage.GEN_PARAMETER__GEN_OPERATION: 197 return eBasicSetContainer(null, GenModelPackage.GEN_PARAMETER__GEN_OPERATION, msgs); 198 default: 199 return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); 200 } 201 } 202 return eBasicSetContainer(null, featureID, msgs); 203 } 204 205 210 public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) 211 { 212 if (eContainerFeatureID >= 0) 213 { 214 switch (eContainerFeatureID) 215 { 216 case GenModelPackage.GEN_PARAMETER__GEN_OPERATION: 217 return eContainer.eInverseRemove(this, GenModelPackage.GEN_OPERATION__GEN_PARAMETERS, GenOperation.class, msgs); 218 default: 219 return eDynamicBasicRemoveFromContainer(msgs); 220 } 221 } 222 return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs); 223 } 224 225 230 public Object eGet(EStructuralFeature eFeature, boolean resolve) 231 { 232 switch (eDerivedStructuralFeatureID(eFeature)) 233 { 234 case GenModelPackage.GEN_PARAMETER__GEN_OPERATION: 235 return getGenOperation(); 236 case GenModelPackage.GEN_PARAMETER__ECORE_PARAMETER: 237 if (resolve) return getEcoreParameter(); 238 return basicGetEcoreParameter(); 239 } 240 return eDynamicGet(eFeature, resolve); 241 } 242 243 248 public boolean eIsSet(EStructuralFeature eFeature) 249 { 250 switch (eDerivedStructuralFeatureID(eFeature)) 251 { 252 case GenModelPackage.GEN_PARAMETER__GEN_OPERATION: 253 return getGenOperation() != null; 254 case GenModelPackage.GEN_PARAMETER__ECORE_PARAMETER: 255 return ecoreParameter != null; 256 } 257 return eDynamicIsSet(eFeature); 258 } 259 260 265 public void eSet(EStructuralFeature eFeature, Object newValue) 266 { 267 switch (eDerivedStructuralFeatureID(eFeature)) 268 { 269 case GenModelPackage.GEN_PARAMETER__GEN_OPERATION: 270 setGenOperation((GenOperation)newValue); 271 return; 272 case GenModelPackage.GEN_PARAMETER__ECORE_PARAMETER: 273 setEcoreParameter((EParameter)newValue); 274 return; 275 } 276 eDynamicSet(eFeature, newValue); 277 } 278 279 284 public void eUnset(EStructuralFeature eFeature) 285 { 286 switch (eDerivedStructuralFeatureID(eFeature)) 287 { 288 case GenModelPackage.GEN_PARAMETER__GEN_OPERATION: 289 setGenOperation((GenOperation)null); 290 return; 291 case GenModelPackage.GEN_PARAMETER__ECORE_PARAMETER: 292 setEcoreParameter((EParameter)null); 293 return; 294 } 295 eDynamicUnset(eFeature); 296 } 297 298 public ETypedElement getEcoreTypedElement() 299 { 300 return getEcoreParameter(); 301 } 302 303 public String getName() 304 { 305 return getEcoreParameter().getName(); 306 } 307 308 public GenPackage getGenPackage() 309 { 310 return getGenOperation().getGenPackage(); 311 } 312 313 public void initialize(EParameter eParameter) 314 { 315 setEcoreParameter(eParameter); 316 } 317 318 public boolean reconcile(GenParameter oldGenParameterVersion) 319 { 320 if (getEcoreParameter().getName().equals(oldGenParameterVersion.getEcoreParameter().getName())) 321 { 322 reconcileSettings(oldGenParameterVersion); 323 return true; 324 } 325 else 326 { 327 return false; 328 } 329 } 330 331 public String getQualifiedModelInfo() 332 { 333 return getModelInfo(true); 334 } 335 336 protected String getModelInfo(boolean qualified) 337 { 338 EParameter eParameter = getEcoreParameter(); 339 StringBuffer result = new StringBuffer (); 340 341 String mapModelInfo = getMapModelInfo(qualified, true); 342 if (mapModelInfo != null) 343 { 344 result.append(mapModelInfo); 345 } 346 else 347 { 348 if (eParameter.isMany() && !isFeatureMapType()) 349 { 350 appendModelSetting(result, qualified, "type", getType(eParameter.getEType(), false)); 351 } 352 353 EClassifier type = eParameter.getEType(); 354 if (type instanceof EDataType && !(type instanceof EEnum)) 355 { 356 GenPackage genPackage = findGenPackage(type.getEPackage()); 357 if (genPackage != null && (isFeatureMapType() || !genPackage.isEcorePackage())) 358 { 359 appendModelSetting(result, qualified, "dataType", genPackage.getInterfacePackageName() + '.' + type.getName()); 360 } 361 } 362 363 if (!eParameter.isUnique()) 364 { 365 appendModelSetting(result, qualified, "unique", "false"); 366 } 367 368 result.append(getMultiplicityModelInfo(qualified)); 369 370 if (!eParameter.isOrdered()) 371 { 372 appendModelSetting(result, qualified, "ordered", "false"); 373 } 374 } 375 376 appendAnnotationInfo(result, qualified, eParameter, DEFAULT_ANNOTATION_FILTER); 377 return result.toString().trim(); 378 } 379 380 protected void reconcileSettings(GenParameter oldGenParameterVersion) 381 { 382 } 383 384 public boolean reconcile() 385 { 386 EParameter eParameter = getEcoreParameter(); 387 if (eParameter == null || eParameter.eIsProxy() || eParameter.eResource() == null) 388 { 389 return false; 390 } 391 else 392 { 393 return true; 394 } 395 } 396 } 397 | Popular Tags |