blob: 3a9a89fd73b285d91e7041af9a969988a61afff7 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2015 Willink Transformations and others.
* 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:
* E.D.Willink - initial API and implementation
*******************************************************************************/
/**
*/
package simpleuml2rdbms.uml.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.emf.ecore.util.EcoreUtil;
import simpleuml2rdbms.uml.Attribute;
import simpleuml2rdbms.uml.Classifier;
import simpleuml2rdbms.uml.UMLPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Attribute</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link simpleuml2rdbms.uml.impl.AttributeImpl#getOwner <em>Owner</em>}</li>
* <li>{@link simpleuml2rdbms.uml.impl.AttributeImpl#getType <em>Type</em>}</li>
* </ul>
*
* @generated
*/
public class AttributeImpl extends UMLModelElementImpl implements Attribute {
/**
* The cached value of the '{@link #getType() <em>Type</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getType()
* @generated
* @ordered
*/
protected Classifier type;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected AttributeImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return UMLPackage.Literals.ATTRIBUTE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public simpleuml2rdbms.uml.Class getOwner() {
if (eContainerFeatureID() != UMLPackage.ATTRIBUTE__OWNER) return null;
return (simpleuml2rdbms.uml.Class)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOwner(simpleuml2rdbms.uml.Class newOwner, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newOwner, UMLPackage.ATTRIBUTE__OWNER, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setOwner(simpleuml2rdbms.uml.Class newOwner) {
if (newOwner != eInternalContainer() || (eContainerFeatureID() != UMLPackage.ATTRIBUTE__OWNER && newOwner != null)) {
if (EcoreUtil.isAncestor(this, newOwner))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newOwner != null)
msgs = ((InternalEObject)newOwner).eInverseAdd(this, UMLPackage.CLASS__ATTRIBUTES, simpleuml2rdbms.uml.Class.class, msgs);
msgs = basicSetOwner(newOwner, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, UMLPackage.ATTRIBUTE__OWNER, newOwner, newOwner));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Classifier getType() {
if (type != null && type.eIsProxy()) {
InternalEObject oldType = (InternalEObject)type;
type = (Classifier)eResolveProxy(oldType);
if (type != oldType) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, UMLPackage.ATTRIBUTE__TYPE, oldType, type));
}
}
return type;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Classifier basicGetType() {
return type;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetType(Classifier newType, NotificationChain msgs) {
Classifier oldType = type;
type = newType;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UMLPackage.ATTRIBUTE__TYPE, oldType, newType);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setType(Classifier newType) {
if (newType != type) {
NotificationChain msgs = null;
if (type != null)
msgs = ((InternalEObject)type).eInverseRemove(this, UMLPackage.CLASSIFIER__TYPE_OPPOSITE, Classifier.class, msgs);
if (newType != null)
msgs = ((InternalEObject)newType).eInverseAdd(this, UMLPackage.CLASSIFIER__TYPE_OPPOSITE, Classifier.class, msgs);
msgs = basicSetType(newType, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, UMLPackage.ATTRIBUTE__TYPE, newType, newType));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case UMLPackage.ATTRIBUTE__OWNER:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetOwner((simpleuml2rdbms.uml.Class)otherEnd, msgs);
case UMLPackage.ATTRIBUTE__TYPE:
if (type != null)
msgs = ((InternalEObject)type).eInverseRemove(this, UMLPackage.CLASSIFIER__TYPE_OPPOSITE, Classifier.class, msgs);
return basicSetType((Classifier)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 UMLPackage.ATTRIBUTE__OWNER:
return basicSetOwner(null, msgs);
case UMLPackage.ATTRIBUTE__TYPE:
return basicSetType(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case UMLPackage.ATTRIBUTE__OWNER:
return eInternalContainer().eInverseRemove(this, UMLPackage.CLASS__ATTRIBUTES, simpleuml2rdbms.uml.Class.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 UMLPackage.ATTRIBUTE__OWNER:
return getOwner();
case UMLPackage.ATTRIBUTE__TYPE:
if (resolve) return getType();
return basicGetType();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case UMLPackage.ATTRIBUTE__OWNER:
setOwner((simpleuml2rdbms.uml.Class)newValue);
return;
case UMLPackage.ATTRIBUTE__TYPE:
setType((Classifier)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case UMLPackage.ATTRIBUTE__OWNER:
setOwner((simpleuml2rdbms.uml.Class)null);
return;
case UMLPackage.ATTRIBUTE__TYPE:
setType((Classifier)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case UMLPackage.ATTRIBUTE__OWNER:
return getOwner() != null;
case UMLPackage.ATTRIBUTE__TYPE:
return type != null;
}
return super.eIsSet(featureID);
}
} //AttributeImpl