1 17 package org.eclipse.emf.ecore.impl; 18 19 20 import java.util.Collection ; 21 22 import org.eclipse.emf.common.notify.NotificationChain; 23 import org.eclipse.emf.common.util.EList; 24 import org.eclipse.emf.ecore.EClass; 25 import org.eclipse.emf.ecore.EClassifier; 26 import org.eclipse.emf.ecore.EOperation; 27 import org.eclipse.emf.ecore.EParameter; 28 import org.eclipse.emf.ecore.EStructuralFeature; 29 import org.eclipse.emf.ecore.EcorePackage; 30 import org.eclipse.emf.ecore.InternalEObject; 31 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; 32 import org.eclipse.emf.ecore.util.EObjectResolvingEList; 33 import org.eclipse.emf.ecore.util.InternalEList; 34 35 36 51 public class EOperationImpl extends ETypedElementImpl implements EOperation 52 { 53 61 protected EList eParameters = null; 62 63 71 protected EList eExceptions = null; 72 73 78 protected EOperationImpl() 79 { 80 super(); 81 } 82 83 88 protected EClass eStaticClass() 89 { 90 return EcorePackage.eINSTANCE.getEOperation(); 91 } 92 93 98 public EClass getEContainingClass() 99 { 100 return (eContainerFeatureID == EcorePackage.EOPERATION__ECONTAINING_CLASS) ? (EClass)eContainer : null; 101 } 102 103 108 public EList getEParameters() 109 { 110 if (eParameters == null) 111 { 112 eParameters = new EObjectContainmentWithInverseEList(EParameter.class, this, EcorePackage.EOPERATION__EPARAMETERS, EcorePackage.EPARAMETER__EOPERATION); 113 } 114 return eParameters; 115 } 116 117 122 public EList getEExceptions() 123 { 124 if (eExceptions == null) 125 { 126 eExceptions = new EObjectResolvingEList(EClassifier.class, this, EcorePackage.EOPERATION__EEXCEPTIONS); 127 } 128 return eExceptions; 129 } 130 131 136 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) 137 { 138 if (featureID >= 0) 139 { 140 switch (eDerivedStructuralFeatureID(featureID, baseClass)) 141 { 142 case EcorePackage.EOPERATION__EANNOTATIONS: 143 return ((InternalEList)getEAnnotations()).basicAdd(otherEnd, msgs); 144 case EcorePackage.EOPERATION__ECONTAINING_CLASS: 145 if (eContainer != null) 146 msgs = eBasicRemoveFromContainer(msgs); 147 return eBasicSetContainer(otherEnd, EcorePackage.EOPERATION__ECONTAINING_CLASS, msgs); 148 case EcorePackage.EOPERATION__EPARAMETERS: 149 return ((InternalEList)getEParameters()).basicAdd(otherEnd, msgs); 150 default: 151 return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); 152 } 153 } 154 if (eContainer != null) 155 msgs = eBasicRemoveFromContainer(msgs); 156 return eBasicSetContainer(otherEnd, featureID, msgs); 157 } 158 159 164 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) 165 { 166 if (featureID >= 0) 167 { 168 switch (eDerivedStructuralFeatureID(featureID, baseClass)) 169 { 170 case EcorePackage.EOPERATION__EANNOTATIONS: 171 return ((InternalEList)getEAnnotations()).basicRemove(otherEnd, msgs); 172 case EcorePackage.EOPERATION__ECONTAINING_CLASS: 173 return eBasicSetContainer(null, EcorePackage.EOPERATION__ECONTAINING_CLASS, msgs); 174 case EcorePackage.EOPERATION__EPARAMETERS: 175 return ((InternalEList)getEParameters()).basicRemove(otherEnd, msgs); 176 default: 177 return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); 178 } 179 } 180 return eBasicSetContainer(null, featureID, msgs); 181 } 182 183 188 public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) 189 { 190 if (eContainerFeatureID >= 0) 191 { 192 switch (eContainerFeatureID) 193 { 194 case EcorePackage.EOPERATION__ECONTAINING_CLASS: 195 return eContainer.eInverseRemove(this, EcorePackage.ECLASS__EOPERATIONS, EClass.class, msgs); 196 default: 197 return eDynamicBasicRemoveFromContainer(msgs); 198 } 199 } 200 return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs); 201 } 202 203 208 public Object eGet(EStructuralFeature eFeature, boolean resolve) 209 { 210 switch (eDerivedStructuralFeatureID(eFeature)) 211 { 212 case EcorePackage.EOPERATION__EANNOTATIONS: 213 return getEAnnotations(); 214 case EcorePackage.EOPERATION__NAME: 215 return getName(); 216 case EcorePackage.EOPERATION__ORDERED: 217 return isOrdered() ? Boolean.TRUE : Boolean.FALSE; 218 case EcorePackage.EOPERATION__UNIQUE: 219 return isUnique() ? Boolean.TRUE : Boolean.FALSE; 220 case EcorePackage.EOPERATION__LOWER_BOUND: 221 return new Integer (getLowerBound()); 222 case EcorePackage.EOPERATION__UPPER_BOUND: 223 return new Integer (getUpperBound()); 224 case EcorePackage.EOPERATION__MANY: 225 return isMany() ? Boolean.TRUE : Boolean.FALSE; 226 case EcorePackage.EOPERATION__REQUIRED: 227 return isRequired() ? Boolean.TRUE : Boolean.FALSE; 228 case EcorePackage.EOPERATION__ETYPE: 229 if (resolve) return getEType(); 230 return basicGetEType(); 231 case EcorePackage.EOPERATION__ECONTAINING_CLASS: 232 return getEContainingClass(); 233 case EcorePackage.EOPERATION__EPARAMETERS: 234 return getEParameters(); 235 case EcorePackage.EOPERATION__EEXCEPTIONS: 236 return getEExceptions(); 237 } 238 return eDynamicGet(eFeature, resolve); 239 } 240 241 246 public boolean eIsSet(EStructuralFeature eFeature) 247 { 248 switch (eDerivedStructuralFeatureID(eFeature)) 249 { 250 case EcorePackage.EOPERATION__EANNOTATIONS: 251 return eAnnotations != null && !eAnnotations.isEmpty(); 252 case EcorePackage.EOPERATION__NAME: 253 return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); 254 case EcorePackage.EOPERATION__ORDERED: 255 return ((eFlags & ORDERED_EFLAG) != 0) != ORDERED_EDEFAULT; 256 case EcorePackage.EOPERATION__UNIQUE: 257 return ((eFlags & UNIQUE_EFLAG) != 0) != UNIQUE_EDEFAULT; 258 case EcorePackage.EOPERATION__LOWER_BOUND: 259 return lowerBound != LOWER_BOUND_EDEFAULT; 260 case EcorePackage.EOPERATION__UPPER_BOUND: 261 return upperBound != UPPER_BOUND_EDEFAULT; 262 case EcorePackage.EOPERATION__MANY: 263 return isMany() != MANY_EDEFAULT; 264 case EcorePackage.EOPERATION__REQUIRED: 265 return isRequired() != REQUIRED_EDEFAULT; 266 case EcorePackage.EOPERATION__ETYPE: 267 return eType != null; 268 case EcorePackage.EOPERATION__ECONTAINING_CLASS: 269 return getEContainingClass() != null; 270 case EcorePackage.EOPERATION__EPARAMETERS: 271 return eParameters != null && !eParameters.isEmpty(); 272 case EcorePackage.EOPERATION__EEXCEPTIONS: 273 return eExceptions != null && !eExceptions.isEmpty(); 274 } 275 return eDynamicIsSet(eFeature); 276 } 277 278 283 public void eSet(EStructuralFeature eFeature, Object newValue) 284 { 285 switch (eDerivedStructuralFeatureID(eFeature)) 286 { 287 case EcorePackage.EOPERATION__EANNOTATIONS: 288 getEAnnotations().clear(); 289 getEAnnotations().addAll((Collection )newValue); 290 return; 291 case EcorePackage.EOPERATION__NAME: 292 setName((String )newValue); 293 return; 294 case EcorePackage.EOPERATION__ORDERED: 295 setOrdered(((Boolean )newValue).booleanValue()); 296 return; 297 case EcorePackage.EOPERATION__UNIQUE: 298 setUnique(((Boolean )newValue).booleanValue()); 299 return; 300 case EcorePackage.EOPERATION__LOWER_BOUND: 301 setLowerBound(((Integer )newValue).intValue()); 302 return; 303 case EcorePackage.EOPERATION__UPPER_BOUND: 304 setUpperBound(((Integer )newValue).intValue()); 305 return; 306 case EcorePackage.EOPERATION__ETYPE: 307 setEType((EClassifier)newValue); 308 return; 309 case EcorePackage.EOPERATION__EPARAMETERS: 310 getEParameters().clear(); 311 getEParameters().addAll((Collection )newValue); 312 return; 313 case EcorePackage.EOPERATION__EEXCEPTIONS: 314 getEExceptions().clear(); 315 getEExceptions().addAll((Collection )newValue); 316 return; 317 } 318 eDynamicSet(eFeature, newValue); 319 } 320 321 326 public void eUnset(EStructuralFeature eFeature) 327 { 328 switch (eDerivedStructuralFeatureID(eFeature)) 329 { 330 case EcorePackage.EOPERATION__EANNOTATIONS: 331 getEAnnotations().clear(); 332 return; 333 case EcorePackage.EOPERATION__NAME: 334 setName(NAME_EDEFAULT); 335 return; 336 case EcorePackage.EOPERATION__ORDERED: 337 setOrdered(ORDERED_EDEFAULT); 338 return; 339 case EcorePackage.EOPERATION__UNIQUE: 340 setUnique(UNIQUE_EDEFAULT); 341 return; 342 case EcorePackage.EOPERATION__LOWER_BOUND: 343 setLowerBound(LOWER_BOUND_EDEFAULT); 344 return; 345 case EcorePackage.EOPERATION__UPPER_BOUND: 346 setUpperBound(UPPER_BOUND_EDEFAULT); 347 return; 348 case EcorePackage.EOPERATION__ETYPE: 349 setEType((EClassifier)null); 350 return; 351 case EcorePackage.EOPERATION__EPARAMETERS: 352 getEParameters().clear(); 353 return; 354 case EcorePackage.EOPERATION__EEXCEPTIONS: 355 getEExceptions().clear(); 356 return; 357 } 358 eDynamicUnset(eFeature); 359 } 360 361 } 362 | Popular Tags |