/*******************************************************************************
* Copyright (c) 2008, 2011 Obeo.
* 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:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.emf.eef.modelingBot.EEFActions.impl;
import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.eef.extended.editor.ReferenceableObject;
import org.eclipse.emf.eef.modelingBot.EEFActions.EEFActionsPackage;
import org.eclipse.emf.eef.modelingBot.EEFActions.SetReference;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Set Reference</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.emf.eef.modelingBot.EEFActions.impl.SetReferenceImpl#getValues <em>Values</em>}</li>
* <li>{@link org.eclipse.emf.eef.modelingBot.EEFActions.impl.SetReferenceImpl#getEContainingFeature <em>EContaining Feature</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class SetReferenceImpl extends EditActionImpl implements SetReference {
/**
* The cached value of the '{@link #getValues() <em>Values</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getValues()
* @generated
* @ordered
*/
protected EList<ReferenceableObject> values;
/**
* The cached value of the '{@link #getEContainingFeature() <em>EContaining Feature</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getEContainingFeature()
* @generated
* @ordered
*/
protected EStructuralFeature eContainingFeature;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected SetReferenceImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return EEFActionsPackage.Literals.SET_REFERENCE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<ReferenceableObject> getValues() {
if (values == null) {
values = new EObjectResolvingEList<ReferenceableObject>(ReferenceableObject.class, this, EEFActionsPackage.SET_REFERENCE__VALUES);
}
return values;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EStructuralFeature getEContainingFeature() {
if (eContainingFeature != null && eContainingFeature.eIsProxy()) {
InternalEObject oldEContainingFeature = (InternalEObject)eContainingFeature;
eContainingFeature = (EStructuralFeature)eResolveProxy(oldEContainingFeature);
if (eContainingFeature != oldEContainingFeature) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, EEFActionsPackage.SET_REFERENCE__ECONTAINING_FEATURE, oldEContainingFeature, eContainingFeature));
}
}
return eContainingFeature;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EStructuralFeature basicGetEContainingFeature() {
return eContainingFeature;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setEContainingFeature(EStructuralFeature newEContainingFeature) {
EStructuralFeature oldEContainingFeature = eContainingFeature;
eContainingFeature = newEContainingFeature;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, EEFActionsPackage.SET_REFERENCE__ECONTAINING_FEATURE, oldEContainingFeature, eContainingFeature));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case EEFActionsPackage.SET_REFERENCE__VALUES:
return getValues();
case EEFActionsPackage.SET_REFERENCE__ECONTAINING_FEATURE:
if (resolve) return getEContainingFeature();
return basicGetEContainingFeature();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case EEFActionsPackage.SET_REFERENCE__VALUES:
getValues().clear();
getValues().addAll((Collection<? extends ReferenceableObject>)newValue);
return;
case EEFActionsPackage.SET_REFERENCE__ECONTAINING_FEATURE:
setEContainingFeature((EStructuralFeature)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case EEFActionsPackage.SET_REFERENCE__VALUES:
getValues().clear();
return;
case EEFActionsPackage.SET_REFERENCE__ECONTAINING_FEATURE:
setEContainingFeature((EStructuralFeature)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case EEFActionsPackage.SET_REFERENCE__VALUES:
return values != null && !values.isEmpty();
case EEFActionsPackage.SET_REFERENCE__ECONTAINING_FEATURE:
return eContainingFeature != null;
}
return super.eIsSet(featureID);
}
} //SetReferenceImpl