blob: 472eb1d306b6252c0fa11bb2ac10611f15d96518 [file] [log] [blame]
/**
* *******************************************************************************
* Copyright (c) 2009 Mia-Software.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sebastien Minguet (Mia-Software) - initial API and implementation
* Frederic Madiot (Mia-Software) - initial API and implementation
* Fabien Giquel (Mia-Software) - initial API and implementation
* Gabriel Barbier (Mia-Software) - initial API and implementation
* Erwan Breton (Sodifrance) - initial API and implementation
* Romain Dervaux (Mia-Software) - initial API and implementation
* *******************************************************************************
*
* $Id$
*/
package org.eclipse.gmt.modisco.java.emf.impl;
import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.gmt.modisco.java.AbstractTypeDeclaration;
import org.eclipse.gmt.modisco.java.BodyDeclaration;
import org.eclipse.gmt.modisco.java.Comment;
import org.eclipse.gmt.modisco.java.Type;
import org.eclipse.gmt.modisco.java.TypeAccess;
import org.eclipse.gmt.modisco.java.emf.JavaPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Abstract Type Declaration</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.gmt.modisco.java.emf.impl.AbstractTypeDeclarationImpl#getUsagesInTypeAccess <em>Usages In Type Access</em>}</li>
* <li>{@link org.eclipse.gmt.modisco.java.emf.impl.AbstractTypeDeclarationImpl#getBodyDeclarations <em>Body Declarations</em>}</li>
* <li>{@link org.eclipse.gmt.modisco.java.emf.impl.AbstractTypeDeclarationImpl#getCommentsBeforeBody <em>Comments Before Body</em>}</li>
* <li>{@link org.eclipse.gmt.modisco.java.emf.impl.AbstractTypeDeclarationImpl#getCommentsAfterBody <em>Comments After Body</em>}</li>
* <li>{@link org.eclipse.gmt.modisco.java.emf.impl.AbstractTypeDeclarationImpl#getPackage <em>Package</em>}</li>
* <li>{@link org.eclipse.gmt.modisco.java.emf.impl.AbstractTypeDeclarationImpl#getSuperInterfaces <em>Super Interfaces</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public abstract class AbstractTypeDeclarationImpl extends BodyDeclarationImpl implements AbstractTypeDeclaration {
/**
* The cached value of the '{@link #getUsagesInTypeAccess() <em>Usages In Type Access</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getUsagesInTypeAccess()
* @generated
* @ordered
*/
protected EList<TypeAccess> usagesInTypeAccess;
/**
* The cached value of the '{@link #getBodyDeclarations() <em>Body Declarations</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBodyDeclarations()
* @generated
* @ordered
*/
protected EList<BodyDeclaration> bodyDeclarations;
/**
* The cached value of the '{@link #getCommentsBeforeBody() <em>Comments Before Body</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCommentsBeforeBody()
* @generated
* @ordered
*/
protected EList<Comment> commentsBeforeBody;
/**
* The cached value of the '{@link #getCommentsAfterBody() <em>Comments After Body</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCommentsAfterBody()
* @generated
* @ordered
*/
protected EList<Comment> commentsAfterBody;
/**
* The cached value of the '{@link #getSuperInterfaces() <em>Super Interfaces</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSuperInterfaces()
* @generated
* @ordered
*/
protected EList<TypeAccess> superInterfaces;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected AbstractTypeDeclarationImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return JavaPackage.eINSTANCE.getAbstractTypeDeclaration();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<TypeAccess> getUsagesInTypeAccess() {
if (usagesInTypeAccess == null) {
usagesInTypeAccess = new EObjectWithInverseResolvingEList<TypeAccess>(TypeAccess.class, this, JavaPackage.ABSTRACT_TYPE_DECLARATION__USAGES_IN_TYPE_ACCESS, JavaPackage.TYPE_ACCESS__TYPE);
}
return usagesInTypeAccess;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<BodyDeclaration> getBodyDeclarations() {
if (bodyDeclarations == null) {
bodyDeclarations = new EObjectContainmentWithInverseEList<BodyDeclaration>(BodyDeclaration.class, this, JavaPackage.ABSTRACT_TYPE_DECLARATION__BODY_DECLARATIONS, JavaPackage.BODY_DECLARATION__ABSTRACT_TYPE_DECLARATION);
}
return bodyDeclarations;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Comment> getCommentsBeforeBody() {
if (commentsBeforeBody == null) {
commentsBeforeBody = new EObjectContainmentEList<Comment>(Comment.class, this, JavaPackage.ABSTRACT_TYPE_DECLARATION__COMMENTS_BEFORE_BODY);
}
return commentsBeforeBody;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Comment> getCommentsAfterBody() {
if (commentsAfterBody == null) {
commentsAfterBody = new EObjectContainmentEList<Comment>(Comment.class, this, JavaPackage.ABSTRACT_TYPE_DECLARATION__COMMENTS_AFTER_BODY);
}
return commentsAfterBody;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public org.eclipse.gmt.modisco.java.Package getPackage() {
if (eContainerFeatureID() != JavaPackage.ABSTRACT_TYPE_DECLARATION__PACKAGE) return null;
return (org.eclipse.gmt.modisco.java.Package)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetPackage(org.eclipse.gmt.modisco.java.Package newPackage, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newPackage, JavaPackage.ABSTRACT_TYPE_DECLARATION__PACKAGE, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setPackage(org.eclipse.gmt.modisco.java.Package newPackage) {
if (newPackage != eInternalContainer() || (eContainerFeatureID() != JavaPackage.ABSTRACT_TYPE_DECLARATION__PACKAGE && newPackage != null)) {
if (EcoreUtil.isAncestor(this, newPackage))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newPackage != null)
msgs = ((InternalEObject)newPackage).eInverseAdd(this, JavaPackage.PACKAGE__OWNED_ELEMENTS, org.eclipse.gmt.modisco.java.Package.class, msgs);
msgs = basicSetPackage(newPackage, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.ABSTRACT_TYPE_DECLARATION__PACKAGE, newPackage, newPackage));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<TypeAccess> getSuperInterfaces() {
if (superInterfaces == null) {
superInterfaces = new EObjectContainmentEList<TypeAccess>(TypeAccess.class, this, JavaPackage.ABSTRACT_TYPE_DECLARATION__SUPER_INTERFACES);
}
return superInterfaces;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case JavaPackage.ABSTRACT_TYPE_DECLARATION__USAGES_IN_TYPE_ACCESS:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getUsagesInTypeAccess()).basicAdd(otherEnd, msgs);
case JavaPackage.ABSTRACT_TYPE_DECLARATION__BODY_DECLARATIONS:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getBodyDeclarations()).basicAdd(otherEnd, msgs);
case JavaPackage.ABSTRACT_TYPE_DECLARATION__PACKAGE:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetPackage((org.eclipse.gmt.modisco.java.Package)otherEnd, msgs);
}
return super.eInverseAdd(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case JavaPackage.ABSTRACT_TYPE_DECLARATION__USAGES_IN_TYPE_ACCESS:
return ((InternalEList<?>)getUsagesInTypeAccess()).basicRemove(otherEnd, msgs);
case JavaPackage.ABSTRACT_TYPE_DECLARATION__BODY_DECLARATIONS:
return ((InternalEList<?>)getBodyDeclarations()).basicRemove(otherEnd, msgs);
case JavaPackage.ABSTRACT_TYPE_DECLARATION__COMMENTS_BEFORE_BODY:
return ((InternalEList<?>)getCommentsBeforeBody()).basicRemove(otherEnd, msgs);
case JavaPackage.ABSTRACT_TYPE_DECLARATION__COMMENTS_AFTER_BODY:
return ((InternalEList<?>)getCommentsAfterBody()).basicRemove(otherEnd, msgs);
case JavaPackage.ABSTRACT_TYPE_DECLARATION__PACKAGE:
return basicSetPackage(null, msgs);
case JavaPackage.ABSTRACT_TYPE_DECLARATION__SUPER_INTERFACES:
return ((InternalEList<?>)getSuperInterfaces()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case JavaPackage.ABSTRACT_TYPE_DECLARATION__PACKAGE:
return eInternalContainer().eInverseRemove(this, JavaPackage.PACKAGE__OWNED_ELEMENTS, org.eclipse.gmt.modisco.java.Package.class, msgs);
}
return super.eBasicRemoveFromContainerFeature(msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case JavaPackage.ABSTRACT_TYPE_DECLARATION__USAGES_IN_TYPE_ACCESS:
return getUsagesInTypeAccess();
case JavaPackage.ABSTRACT_TYPE_DECLARATION__BODY_DECLARATIONS:
return getBodyDeclarations();
case JavaPackage.ABSTRACT_TYPE_DECLARATION__COMMENTS_BEFORE_BODY:
return getCommentsBeforeBody();
case JavaPackage.ABSTRACT_TYPE_DECLARATION__COMMENTS_AFTER_BODY:
return getCommentsAfterBody();
case JavaPackage.ABSTRACT_TYPE_DECLARATION__PACKAGE:
return getPackage();
case JavaPackage.ABSTRACT_TYPE_DECLARATION__SUPER_INTERFACES:
return getSuperInterfaces();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case JavaPackage.ABSTRACT_TYPE_DECLARATION__USAGES_IN_TYPE_ACCESS:
getUsagesInTypeAccess().clear();
getUsagesInTypeAccess().addAll((Collection<? extends TypeAccess>)newValue);
return;
case JavaPackage.ABSTRACT_TYPE_DECLARATION__BODY_DECLARATIONS:
getBodyDeclarations().clear();
getBodyDeclarations().addAll((Collection<? extends BodyDeclaration>)newValue);
return;
case JavaPackage.ABSTRACT_TYPE_DECLARATION__COMMENTS_BEFORE_BODY:
getCommentsBeforeBody().clear();
getCommentsBeforeBody().addAll((Collection<? extends Comment>)newValue);
return;
case JavaPackage.ABSTRACT_TYPE_DECLARATION__COMMENTS_AFTER_BODY:
getCommentsAfterBody().clear();
getCommentsAfterBody().addAll((Collection<? extends Comment>)newValue);
return;
case JavaPackage.ABSTRACT_TYPE_DECLARATION__PACKAGE:
setPackage((org.eclipse.gmt.modisco.java.Package)newValue);
return;
case JavaPackage.ABSTRACT_TYPE_DECLARATION__SUPER_INTERFACES:
getSuperInterfaces().clear();
getSuperInterfaces().addAll((Collection<? extends TypeAccess>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case JavaPackage.ABSTRACT_TYPE_DECLARATION__USAGES_IN_TYPE_ACCESS:
getUsagesInTypeAccess().clear();
return;
case JavaPackage.ABSTRACT_TYPE_DECLARATION__BODY_DECLARATIONS:
getBodyDeclarations().clear();
return;
case JavaPackage.ABSTRACT_TYPE_DECLARATION__COMMENTS_BEFORE_BODY:
getCommentsBeforeBody().clear();
return;
case JavaPackage.ABSTRACT_TYPE_DECLARATION__COMMENTS_AFTER_BODY:
getCommentsAfterBody().clear();
return;
case JavaPackage.ABSTRACT_TYPE_DECLARATION__PACKAGE:
setPackage((org.eclipse.gmt.modisco.java.Package)null);
return;
case JavaPackage.ABSTRACT_TYPE_DECLARATION__SUPER_INTERFACES:
getSuperInterfaces().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case JavaPackage.ABSTRACT_TYPE_DECLARATION__USAGES_IN_TYPE_ACCESS:
return usagesInTypeAccess != null && !usagesInTypeAccess.isEmpty();
case JavaPackage.ABSTRACT_TYPE_DECLARATION__BODY_DECLARATIONS:
return bodyDeclarations != null && !bodyDeclarations.isEmpty();
case JavaPackage.ABSTRACT_TYPE_DECLARATION__COMMENTS_BEFORE_BODY:
return commentsBeforeBody != null && !commentsBeforeBody.isEmpty();
case JavaPackage.ABSTRACT_TYPE_DECLARATION__COMMENTS_AFTER_BODY:
return commentsAfterBody != null && !commentsAfterBody.isEmpty();
case JavaPackage.ABSTRACT_TYPE_DECLARATION__PACKAGE:
return getPackage() != null;
case JavaPackage.ABSTRACT_TYPE_DECLARATION__SUPER_INTERFACES:
return superInterfaces != null && !superInterfaces.isEmpty();
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
if (baseClass == Type.class) {
switch (derivedFeatureID) {
case JavaPackage.ABSTRACT_TYPE_DECLARATION__USAGES_IN_TYPE_ACCESS: return JavaPackage.TYPE__USAGES_IN_TYPE_ACCESS;
default: return -1;
}
}
return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) {
if (baseClass == Type.class) {
switch (baseFeatureID) {
case JavaPackage.TYPE__USAGES_IN_TYPE_ACCESS: return JavaPackage.ABSTRACT_TYPE_DECLARATION__USAGES_IN_TYPE_ACCESS;
default: return -1;
}
}
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
} //AbstractTypeDeclarationImpl