blob: 7fe4abadf99e487675b96e93633cd33429e90bc4 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2018 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:
* Adolfo Sanchez-Barbudo Herrera - initial API and implementation
*******************************************************************************/
/**
*/
package org.eclipse.qvtd.doc.miniocl.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.jdt.annotation.NonNull;
import org.eclipse.qvtd.doc.miniocl.Constraint;
import org.eclipse.qvtd.doc.miniocl.ExpressionInOCL;
import org.eclipse.qvtd.doc.miniocl.MiniOCLPackage;
import org.eclipse.qvtd.doc.miniocl.util.Visitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Constraint</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.qvtd.doc.miniocl.impl.ConstraintImpl#getOwnedSpecification <em>Owned Specification</em>}</li>
* <li>{@link org.eclipse.qvtd.doc.miniocl.impl.ConstraintImpl#getConstrainedElement <em>Constrained Element</em>}</li>
* </ul>
*
* @generated
*/
public class ConstraintImpl extends NamedElementImpl implements Constraint {
/**
* The cached value of the '{@link #getOwnedSpecification() <em>Owned Specification</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOwnedSpecification()
* @generated
* @ordered
*/
protected ExpressionInOCL ownedSpecification;
/**
* The cached value of the '{@link #getConstrainedElement() <em>Constrained Element</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getConstrainedElement()
* @generated
* @ordered
*/
protected org.eclipse.qvtd.doc.miniocl.Class constrainedElement;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ConstraintImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return MiniOCLPackage.Literals.CONSTRAINT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ExpressionInOCL getOwnedSpecification() {
return ownedSpecification;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOwnedSpecification(ExpressionInOCL newOwnedSpecification, NotificationChain msgs) {
ExpressionInOCL oldOwnedSpecification = ownedSpecification;
ownedSpecification = newOwnedSpecification;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MiniOCLPackage.CONSTRAINT__OWNED_SPECIFICATION, oldOwnedSpecification, newOwnedSpecification);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setOwnedSpecification(ExpressionInOCL newOwnedSpecification) {
if (newOwnedSpecification != ownedSpecification) {
NotificationChain msgs = null;
if (ownedSpecification != null)
msgs = ((InternalEObject)ownedSpecification).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MiniOCLPackage.CONSTRAINT__OWNED_SPECIFICATION, null, msgs);
if (newOwnedSpecification != null)
msgs = ((InternalEObject)newOwnedSpecification).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MiniOCLPackage.CONSTRAINT__OWNED_SPECIFICATION, null, msgs);
msgs = basicSetOwnedSpecification(newOwnedSpecification, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MiniOCLPackage.CONSTRAINT__OWNED_SPECIFICATION, newOwnedSpecification, newOwnedSpecification));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public org.eclipse.qvtd.doc.miniocl.Class getConstrainedElement() {
if (constrainedElement != null && constrainedElement.eIsProxy()) {
InternalEObject oldConstrainedElement = (InternalEObject)constrainedElement;
constrainedElement = (org.eclipse.qvtd.doc.miniocl.Class)eResolveProxy(oldConstrainedElement);
if (constrainedElement != oldConstrainedElement) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, MiniOCLPackage.CONSTRAINT__CONSTRAINED_ELEMENT, oldConstrainedElement, constrainedElement));
}
}
return constrainedElement;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public org.eclipse.qvtd.doc.miniocl.Class basicGetConstrainedElement() {
return constrainedElement;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setConstrainedElement(org.eclipse.qvtd.doc.miniocl.Class newConstrainedElement) {
org.eclipse.qvtd.doc.miniocl.Class oldConstrainedElement = constrainedElement;
constrainedElement = newConstrainedElement;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MiniOCLPackage.CONSTRAINT__CONSTRAINED_ELEMENT, oldConstrainedElement, constrainedElement));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case MiniOCLPackage.CONSTRAINT__OWNED_SPECIFICATION:
return basicSetOwnedSpecification(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 MiniOCLPackage.CONSTRAINT__OWNED_SPECIFICATION:
return getOwnedSpecification();
case MiniOCLPackage.CONSTRAINT__CONSTRAINED_ELEMENT:
if (resolve) return getConstrainedElement();
return basicGetConstrainedElement();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case MiniOCLPackage.CONSTRAINT__OWNED_SPECIFICATION:
setOwnedSpecification((ExpressionInOCL)newValue);
return;
case MiniOCLPackage.CONSTRAINT__CONSTRAINED_ELEMENT:
setConstrainedElement((org.eclipse.qvtd.doc.miniocl.Class)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case MiniOCLPackage.CONSTRAINT__OWNED_SPECIFICATION:
setOwnedSpecification((ExpressionInOCL)null);
return;
case MiniOCLPackage.CONSTRAINT__CONSTRAINED_ELEMENT:
setConstrainedElement((org.eclipse.qvtd.doc.miniocl.Class)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case MiniOCLPackage.CONSTRAINT__OWNED_SPECIFICATION:
return ownedSpecification != null;
case MiniOCLPackage.CONSTRAINT__CONSTRAINED_ELEMENT:
return constrainedElement != null;
}
return super.eIsSet(featureID);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public <R> R accept(@NonNull Visitor<R> visitor) {
return visitor.visitConstraint(this);
}
} //ConstraintImpl