/* * Copyright (c) 2007 Borland Software Corporation * * 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: * Dmitry Stadnik (Borland) - initial API and implementation */ package org.eclipse.gmf.sketch.impl; import java.util.Collection; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EAnnotation; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.EObjectImpl; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; import org.eclipse.gmf.sketch.SketchElement; import org.eclipse.gmf.sketch.SketchPackage; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Element</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.eclipse.gmf.sketch.impl.SketchElementImpl#getEAnnotations <em>EAnnotations</em>}</li> * </ul> * </p> * * @generated */ public abstract class SketchElementImpl extends EObjectImpl implements SketchElement { /** * The cached value of the '{@link #getEAnnotations() <em>EAnnotations</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getEAnnotations() * @generated * @ordered */ protected EList<EAnnotation> eAnnotations; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected SketchElementImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return SketchPackage.Literals.SKETCH_ELEMENT; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<EAnnotation> getEAnnotations() { if (eAnnotations == null) { eAnnotations = new EObjectContainmentEList<EAnnotation>(EAnnotation.class, this, SketchPackage.SKETCH_ELEMENT__EANNOTATIONS); } return eAnnotations; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ public EAnnotation getEAnnotation(String source) { if (eAnnotations != null) { if (eAnnotations instanceof BasicEList) { int size = eAnnotations.size(); if (size > 0) { EAnnotation[] eAnnotationArray = (EAnnotation[]) ((BasicEList<?>) eAnnotations).data(); if (source == null) { for (int i = 0; i < size; ++i) { EAnnotation eAnnotation = eAnnotationArray[i]; if (eAnnotation.getSource() == null) { return eAnnotation; } } } else { for (int i = 0; i < size; ++i) { EAnnotation eAnnotation = eAnnotationArray[i]; if (source.equals(eAnnotation.getSource())) { return eAnnotation; } } } } } else { if (source == null) { for (EAnnotation eAnnotation : eAnnotations) { if (eAnnotation.getSource() == null) { return eAnnotation; } } } else { for (EAnnotation eAnnotation : eAnnotations) { if (source.equals(eAnnotation.getSource())) { return eAnnotation; } } } } } return null; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case SketchPackage.SKETCH_ELEMENT__EANNOTATIONS: return ((InternalEList<?>) getEAnnotations()).basicRemove(otherEnd, 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 SketchPackage.SKETCH_ELEMENT__EANNOTATIONS: return getEAnnotations(); } 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 SketchPackage.SKETCH_ELEMENT__EANNOTATIONS: getEAnnotations().clear(); getEAnnotations().addAll((Collection<? extends EAnnotation>) newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case SketchPackage.SKETCH_ELEMENT__EANNOTATIONS: getEAnnotations().clear(); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case SketchPackage.SKETCH_ELEMENT__EANNOTATIONS: return eAnnotations != null && !eAnnotations.isEmpty(); } return super.eIsSet(featureID); } } //SketchElementImpl