blob: ac684f30cedb504dacf3f4ab4f28dcf348793a28 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007, 2010 BMW Car IT, Technische Universitaet Muenchen, and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* BMW Car IT - Initial API and implementation
* Technische Universitaet Muenchen - Major refactoring and extension
*******************************************************************************/
package org.eclipse.emf.edapt.declaration.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 org.eclipse.emf.edapt.declaration.Constraint;
import org.eclipse.emf.edapt.declaration.DeclarationPackage;
import org.eclipse.emf.edapt.declaration.Operation;
import org.eclipse.emf.edapt.declaration.Parameter;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Constraint</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.emf.edapt.declaration.impl.ConstraintImpl#getOperation <em>Operation</em>}</li>
* <li>{@link org.eclipse.emf.edapt.declaration.impl.ConstraintImpl#getRestricts <em>Restricts</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ConstraintImpl extends IdentifiedElementImpl implements Constraint {
/**
* The cached value of the '{@link #getRestricts() <em>Restricts</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getRestricts()
* @generated
* @ordered
*/
protected Parameter restricts;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
protected ConstraintImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return DeclarationPackage.Literals.CONSTRAINT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public Operation getOperation() {
if (eContainerFeatureID() != DeclarationPackage.CONSTRAINT__OPERATION) {
return null;
}
return (Operation) eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetOperation(Operation newOperation, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject) newOperation, DeclarationPackage.CONSTRAINT__OPERATION, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setOperation(Operation newOperation) {
if (newOperation != eInternalContainer()
|| eContainerFeatureID() != DeclarationPackage.CONSTRAINT__OPERATION && newOperation != null) {
if (EcoreUtil.isAncestor(this, newOperation)) {
throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
}
NotificationChain msgs = null;
if (eInternalContainer() != null) {
msgs = eBasicRemoveFromContainer(msgs);
}
if (newOperation != null) {
msgs = ((InternalEObject) newOperation).eInverseAdd(this, DeclarationPackage.OPERATION__CONSTRAINTS,
Operation.class, msgs);
}
msgs = basicSetOperation(newOperation, msgs);
if (msgs != null) {
msgs.dispatch();
}
} else if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET, DeclarationPackage.CONSTRAINT__OPERATION,
newOperation, newOperation));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public Parameter getRestricts() {
if (restricts != null && restricts.eIsProxy()) {
final InternalEObject oldRestricts = (InternalEObject) restricts;
restricts = (Parameter) eResolveProxy(oldRestricts);
if (restricts != oldRestricts) {
if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.RESOLVE, DeclarationPackage.CONSTRAINT__RESTRICTS,
oldRestricts, restricts));
}
}
}
return restricts;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public Parameter basicGetRestricts() {
return restricts;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setRestricts(Parameter newRestricts) {
final Parameter oldRestricts = restricts;
restricts = newRestricts;
if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET, DeclarationPackage.CONSTRAINT__RESTRICTS,
oldRestricts, restricts));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case DeclarationPackage.CONSTRAINT__OPERATION:
if (eInternalContainer() != null) {
msgs = eBasicRemoveFromContainer(msgs);
}
return basicSetOperation((Operation) 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 DeclarationPackage.CONSTRAINT__OPERATION:
return basicSetOperation(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case DeclarationPackage.CONSTRAINT__OPERATION:
return eInternalContainer().eInverseRemove(this, DeclarationPackage.OPERATION__CONSTRAINTS,
Operation.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 DeclarationPackage.CONSTRAINT__OPERATION:
return getOperation();
case DeclarationPackage.CONSTRAINT__RESTRICTS:
if (resolve) {
return getRestricts();
}
return basicGetRestricts();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case DeclarationPackage.CONSTRAINT__OPERATION:
setOperation((Operation) newValue);
return;
case DeclarationPackage.CONSTRAINT__RESTRICTS:
setRestricts((Parameter) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case DeclarationPackage.CONSTRAINT__OPERATION:
setOperation((Operation) null);
return;
case DeclarationPackage.CONSTRAINT__RESTRICTS:
setRestricts((Parameter) null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case DeclarationPackage.CONSTRAINT__OPERATION:
return getOperation() != null;
case DeclarationPackage.CONSTRAINT__RESTRICTS:
return restricts != null;
}
return super.eIsSet(featureID);
}
} // ConstraintImpl