blob: 16bef94c6a98b777d15b112eed6a49a5e8729c3b [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:
*
* Fabien Giquel (Mia-Software) - initial API and implementation
* *******************************************************************************
*
* $Id$
*/
package org.eclipse.gmt.modisco.java.emf.classic.impl;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.gmt.modisco.java.ImportDeclaration;
import org.eclipse.gmt.modisco.java.NamedElement;
import org.eclipse.gmt.modisco.java.emf.classic.JavaPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Import Declaration</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.gmt.modisco.java.emf.classic.impl.ImportDeclarationImpl#isStatic <em>Static</em>}</li>
* <li>{@link org.eclipse.gmt.modisco.java.emf.classic.impl.ImportDeclarationImpl#getImportedElement <em>Imported Element</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ImportDeclarationImpl extends ASTNodeImpl implements ImportDeclaration {
/**
* The default value of the '{@link #isStatic() <em>Static</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isStatic()
* @generated
* @ordered
*/
protected static final boolean STATIC_EDEFAULT = false;
/**
* The cached value of the '{@link #isStatic() <em>Static</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isStatic()
* @generated
* @ordered
*/
protected boolean static_ = STATIC_EDEFAULT;
/**
* The cached value of the '{@link #getImportedElement() <em>Imported Element</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getImportedElement()
* @generated
* @ordered
*/
protected NamedElement importedElement;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ImportDeclarationImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return JavaPackage.eINSTANCE.getImportDeclaration();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isStatic() {
return static_;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setStatic(boolean newStatic) {
boolean oldStatic = static_;
static_ = newStatic;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.IMPORT_DECLARATION__STATIC, oldStatic, static_));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NamedElement getImportedElement() {
if (importedElement != null && importedElement.eIsProxy()) {
InternalEObject oldImportedElement = (InternalEObject)importedElement;
importedElement = (NamedElement)eResolveProxy(oldImportedElement);
if (importedElement != oldImportedElement) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, JavaPackage.IMPORT_DECLARATION__IMPORTED_ELEMENT, oldImportedElement, importedElement));
}
}
return importedElement;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NamedElement basicGetImportedElement() {
return importedElement;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetImportedElement(NamedElement newImportedElement, NotificationChain msgs) {
NamedElement oldImportedElement = importedElement;
importedElement = newImportedElement;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JavaPackage.IMPORT_DECLARATION__IMPORTED_ELEMENT, oldImportedElement, newImportedElement);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setImportedElement(NamedElement newImportedElement) {
if (newImportedElement != importedElement) {
NotificationChain msgs = null;
if (importedElement != null)
msgs = ((InternalEObject)importedElement).eInverseRemove(this, JavaPackage.NAMED_ELEMENT__USAGES_IN_IMPORTS, NamedElement.class, msgs);
if (newImportedElement != null)
msgs = ((InternalEObject)newImportedElement).eInverseAdd(this, JavaPackage.NAMED_ELEMENT__USAGES_IN_IMPORTS, NamedElement.class, msgs);
msgs = basicSetImportedElement(newImportedElement, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.IMPORT_DECLARATION__IMPORTED_ELEMENT, newImportedElement, newImportedElement));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case JavaPackage.IMPORT_DECLARATION__IMPORTED_ELEMENT:
if (importedElement != null)
msgs = ((InternalEObject)importedElement).eInverseRemove(this, JavaPackage.NAMED_ELEMENT__USAGES_IN_IMPORTS, NamedElement.class, msgs);
return basicSetImportedElement((NamedElement)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.IMPORT_DECLARATION__IMPORTED_ELEMENT:
return basicSetImportedElement(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case JavaPackage.IMPORT_DECLARATION__STATIC:
return isStatic();
case JavaPackage.IMPORT_DECLARATION__IMPORTED_ELEMENT:
if (resolve) return getImportedElement();
return basicGetImportedElement();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case JavaPackage.IMPORT_DECLARATION__STATIC:
setStatic((Boolean)newValue);
return;
case JavaPackage.IMPORT_DECLARATION__IMPORTED_ELEMENT:
setImportedElement((NamedElement)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case JavaPackage.IMPORT_DECLARATION__STATIC:
setStatic(STATIC_EDEFAULT);
return;
case JavaPackage.IMPORT_DECLARATION__IMPORTED_ELEMENT:
setImportedElement((NamedElement)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case JavaPackage.IMPORT_DECLARATION__STATIC:
return static_ != STATIC_EDEFAULT;
case JavaPackage.IMPORT_DECLARATION__IMPORTED_ELEMENT:
return importedElement != null;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (static: "); //$NON-NLS-1$
result.append(static_);
result.append(')');
return result.toString();
}
} //ImportDeclarationImpl