blob: a40f54258d7ca7fb7d4461c7b9a1fc192a485428 [file] [log] [blame]
/**
* Copyright (c) 2010, 2019 Willink Transformations and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* E.D.Willink - Initial API and implementation
*/
package org.eclipse.ocl.pivot.internal;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
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.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.ocl.pivot.Comment;
import org.eclipse.ocl.pivot.Element;
import org.eclipse.ocl.pivot.ElementExtension;
import org.eclipse.ocl.pivot.InstanceSpecification;
import org.eclipse.ocl.pivot.PivotPackage;
import org.eclipse.ocl.pivot.Property;
import org.eclipse.ocl.pivot.Slot;
import org.eclipse.ocl.pivot.ValueSpecification;
import org.eclipse.ocl.pivot.util.Visitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Slot</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.ocl.pivot.internal.SlotImpl#getDefiningProperty <em>Defining Property</em>}</li>
* <li>{@link org.eclipse.ocl.pivot.internal.SlotImpl#getOwnedValues <em>Owned Values</em>}</li>
* <li>{@link org.eclipse.ocl.pivot.internal.SlotImpl#getOwningInstance <em>Owning Instance</em>}</li>
* </ul>
*
* @generated
*/
public class SlotImpl extends ElementImpl implements Slot
{
/**
* The number of structural features of the '<em>Slot</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
public static final int SLOT_FEATURE_COUNT = ElementImpl.ELEMENT_FEATURE_COUNT + 3;
/**
* The number of operations of the '<em>Slot</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
public static final int SLOT_OPERATION_COUNT = ElementImpl.ELEMENT_OPERATION_COUNT + 0;
/**
* The cached value of the '{@link #getDefiningProperty() <em>Defining Property</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getDefiningProperty()
* @generated
* @ordered
*/
protected Property definingProperty;
/**
* The cached value of the '{@link #getOwnedValues() <em>Owned Values</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOwnedValues()
* @generated
* @ordered
*/
protected EList<ValueSpecification> ownedValues;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected SlotImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return PivotPackage.Literals.SLOT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Property getDefiningProperty()
{
if (definingProperty != null && definingProperty.eIsProxy())
{
InternalEObject oldDefiningProperty = (InternalEObject)definingProperty;
definingProperty = (Property)eResolveProxy(oldDefiningProperty);
if (definingProperty != oldDefiningProperty)
{
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, 4, oldDefiningProperty, definingProperty));
}
}
return definingProperty;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Property basicGetDefiningProperty()
{
return definingProperty;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setDefiningProperty(Property newDefiningProperty)
{
Property oldDefiningProperty = definingProperty;
definingProperty = newDefiningProperty;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, 4, oldDefiningProperty, definingProperty));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public List<ValueSpecification> getOwnedValues()
{
if (ownedValues == null)
{
ownedValues = new EObjectContainmentEList<ValueSpecification>(ValueSpecification.class, this, 5);
}
return ownedValues;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public InstanceSpecification getOwningInstance()
{
if (eContainerFeatureID() != (6)) return null;
return (InstanceSpecification)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOwningInstance(InstanceSpecification newOwningInstance, NotificationChain msgs)
{
msgs = eBasicSetContainer((InternalEObject)newOwningInstance, 6, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setOwningInstance(InstanceSpecification newOwningInstance)
{
if (newOwningInstance != eInternalContainer() || (eContainerFeatureID() != (6) && newOwningInstance != null))
{
if (EcoreUtil.isAncestor(this, newOwningInstance))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newOwningInstance != null)
msgs = ((InternalEObject)newOwningInstance).eInverseAdd(this, 6, InstanceSpecification.class, msgs);
msgs = basicSetOwningInstance(newOwningInstance, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, 6, newOwningInstance, newOwningInstance));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case 0:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getAnnotatingComments()).basicAdd(otherEnd, msgs);
case 2:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getOwnedComments()).basicAdd(otherEnd, msgs);
case 3:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getOwnedExtensions()).basicAdd(otherEnd, msgs);
case 6:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetOwningInstance((InstanceSpecification)otherEnd, msgs);
}
return eDynamicInverseAdd(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case 0:
return ((InternalEList<?>)getAnnotatingComments()).basicRemove(otherEnd, msgs);
case 1:
return ((InternalEList<?>)getOwnedAnnotations()).basicRemove(otherEnd, msgs);
case 2:
return ((InternalEList<?>)getOwnedComments()).basicRemove(otherEnd, msgs);
case 3:
return ((InternalEList<?>)getOwnedExtensions()).basicRemove(otherEnd, msgs);
case 5:
return ((InternalEList<?>)getOwnedValues()).basicRemove(otherEnd, msgs);
case 6:
return basicSetOwningInstance(null, msgs);
}
return eDynamicInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs)
{
switch (eContainerFeatureID())
{
case 6:
return eInternalContainer().eInverseRemove(this, 6, InstanceSpecification.class, msgs);
}
return eDynamicBasicRemoveFromContainer(msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType)
{
switch (featureID)
{
case 0:
return getAnnotatingComments();
case 1:
return getOwnedAnnotations();
case 2:
return getOwnedComments();
case 3:
return getOwnedExtensions();
case 4:
if (resolve) return getDefiningProperty();
return basicGetDefiningProperty();
case 5:
return getOwnedValues();
case 6:
return getOwningInstance();
}
return eDynamicGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue)
{
switch (featureID)
{
case 0:
getAnnotatingComments().clear();
getAnnotatingComments().addAll((Collection<? extends Comment>)newValue);
return;
case 1:
getOwnedAnnotations().clear();
getOwnedAnnotations().addAll((Collection<? extends Element>)newValue);
return;
case 2:
getOwnedComments().clear();
getOwnedComments().addAll((Collection<? extends Comment>)newValue);
return;
case 3:
getOwnedExtensions().clear();
getOwnedExtensions().addAll((Collection<? extends ElementExtension>)newValue);
return;
case 4:
setDefiningProperty((Property)newValue);
return;
case 5:
getOwnedValues().clear();
getOwnedValues().addAll((Collection<? extends ValueSpecification>)newValue);
return;
case 6:
setOwningInstance((InstanceSpecification)newValue);
return;
}
eDynamicSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case 0:
getAnnotatingComments().clear();
return;
case 1:
getOwnedAnnotations().clear();
return;
case 2:
getOwnedComments().clear();
return;
case 3:
getOwnedExtensions().clear();
return;
case 4:
setDefiningProperty((Property)null);
return;
case 5:
getOwnedValues().clear();
return;
case 6:
setOwningInstance((InstanceSpecification)null);
return;
}
eDynamicUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case 0:
return annotatingComments != null && !annotatingComments.isEmpty();
case 1:
return ownedAnnotations != null && !ownedAnnotations.isEmpty();
case 2:
return ownedComments != null && !ownedComments.isEmpty();
case 3:
return ownedExtensions != null && !ownedExtensions.isEmpty();
case 4:
return definingProperty != null;
case 5:
return ownedValues != null && !ownedValues.isEmpty();
case 6:
return getOwningInstance() != null;
}
return eDynamicIsSet(featureID);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public <R> R accept(@NonNull Visitor<R> visitor) {
return visitor.visitSlot(this);
}
} //SlotImpl