| /******************************************************************************* |
| * 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.emf.ecore.util.EcoreUtil; |
| import org.eclipse.jdt.annotation.NonNull; |
| import org.eclipse.qvtd.doc.miniocl.MiniOCLPackage; |
| import org.eclipse.qvtd.doc.miniocl.Property; |
| import org.eclipse.qvtd.doc.miniocl.util.Visitor; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Property</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.qvtd.doc.miniocl.impl.PropertyImpl#getOwningClass <em>Owning Class</em>}</li> |
| * <li>{@link org.eclipse.qvtd.doc.miniocl.impl.PropertyImpl#getLowerBound <em>Lower Bound</em>}</li> |
| * <li>{@link org.eclipse.qvtd.doc.miniocl.impl.PropertyImpl#getUpperBound <em>Upper Bound</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class PropertyImpl extends FeatureImpl implements Property { |
| /** |
| * The default value of the '{@link #getLowerBound() <em>Lower Bound</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getLowerBound() |
| * @generated |
| * @ordered |
| */ |
| protected static final int LOWER_BOUND_EDEFAULT = 0; |
| /** |
| * The cached value of the '{@link #getLowerBound() <em>Lower Bound</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getLowerBound() |
| * @generated |
| * @ordered |
| */ |
| protected int lowerBound = LOWER_BOUND_EDEFAULT; |
| /** |
| * The default value of the '{@link #getUpperBound() <em>Upper Bound</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getUpperBound() |
| * @generated |
| * @ordered |
| */ |
| protected static final int UPPER_BOUND_EDEFAULT = 0; |
| /** |
| * The cached value of the '{@link #getUpperBound() <em>Upper Bound</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getUpperBound() |
| * @generated |
| * @ordered |
| */ |
| protected int upperBound = UPPER_BOUND_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected PropertyImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return MiniOCLPackage.Literals.PROPERTY; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public org.eclipse.qvtd.doc.miniocl.Class getOwningClass() { |
| if (eContainerFeatureID() != MiniOCLPackage.PROPERTY__OWNING_CLASS) return null; |
| return (org.eclipse.qvtd.doc.miniocl.Class)eInternalContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwningClass(org.eclipse.qvtd.doc.miniocl.Class newOwningClass, NotificationChain msgs) { |
| msgs = eBasicSetContainer((InternalEObject)newOwningClass, MiniOCLPackage.PROPERTY__OWNING_CLASS, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setOwningClass(org.eclipse.qvtd.doc.miniocl.Class newOwningClass) { |
| if (newOwningClass != eInternalContainer() || (eContainerFeatureID() != MiniOCLPackage.PROPERTY__OWNING_CLASS && newOwningClass != null)) { |
| if (EcoreUtil.isAncestor(this, newOwningClass)) |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| if (newOwningClass != null) |
| msgs = ((InternalEObject)newOwningClass).eInverseAdd(this, MiniOCLPackage.CLASS__OWNED_PROPERTIES, org.eclipse.qvtd.doc.miniocl.Class.class, msgs); |
| msgs = basicSetOwningClass(newOwningClass, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MiniOCLPackage.PROPERTY__OWNING_CLASS, newOwningClass, newOwningClass)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public int getLowerBound() { |
| return lowerBound; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setLowerBound(int newLowerBound) { |
| int oldLowerBound = lowerBound; |
| lowerBound = newLowerBound; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MiniOCLPackage.PROPERTY__LOWER_BOUND, oldLowerBound, lowerBound)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public int getUpperBound() { |
| return upperBound; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setUpperBound(int newUpperBound) { |
| int oldUpperBound = upperBound; |
| upperBound = newUpperBound; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MiniOCLPackage.PROPERTY__UPPER_BOUND, oldUpperBound, upperBound)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case MiniOCLPackage.PROPERTY__OWNING_CLASS: |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| return basicSetOwningClass((org.eclipse.qvtd.doc.miniocl.Class)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 MiniOCLPackage.PROPERTY__OWNING_CLASS: |
| return basicSetOwningClass(null, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| switch (eContainerFeatureID()) { |
| case MiniOCLPackage.PROPERTY__OWNING_CLASS: |
| return eInternalContainer().eInverseRemove(this, MiniOCLPackage.CLASS__OWNED_PROPERTIES, org.eclipse.qvtd.doc.miniocl.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 MiniOCLPackage.PROPERTY__OWNING_CLASS: |
| return getOwningClass(); |
| case MiniOCLPackage.PROPERTY__LOWER_BOUND: |
| return getLowerBound(); |
| case MiniOCLPackage.PROPERTY__UPPER_BOUND: |
| return getUpperBound(); |
| } |
| 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.PROPERTY__OWNING_CLASS: |
| setOwningClass((org.eclipse.qvtd.doc.miniocl.Class)newValue); |
| return; |
| case MiniOCLPackage.PROPERTY__LOWER_BOUND: |
| setLowerBound((Integer)newValue); |
| return; |
| case MiniOCLPackage.PROPERTY__UPPER_BOUND: |
| setUpperBound((Integer)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case MiniOCLPackage.PROPERTY__OWNING_CLASS: |
| setOwningClass((org.eclipse.qvtd.doc.miniocl.Class)null); |
| return; |
| case MiniOCLPackage.PROPERTY__LOWER_BOUND: |
| setLowerBound(LOWER_BOUND_EDEFAULT); |
| return; |
| case MiniOCLPackage.PROPERTY__UPPER_BOUND: |
| setUpperBound(UPPER_BOUND_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case MiniOCLPackage.PROPERTY__OWNING_CLASS: |
| return getOwningClass() != null; |
| case MiniOCLPackage.PROPERTY__LOWER_BOUND: |
| return lowerBound != LOWER_BOUND_EDEFAULT; |
| case MiniOCLPackage.PROPERTY__UPPER_BOUND: |
| return upperBound != UPPER_BOUND_EDEFAULT; |
| } |
| 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(" (lowerBound: "); |
| result.append(lowerBound); |
| result.append(", upperBound: "); |
| result.append(upperBound); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public <R> R accept(@NonNull Visitor<R> visitor) { |
| return visitor.visitProperty(this); |
| } |
| |
| } //PropertyImpl |