/* * Copyright (c) 2014, 2015 Eike Stepper (Loehne, Germany) 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: * Eike Stepper - initial API and implementation */ package org.eclipse.oomph.base.impl; import org.eclipse.oomph.base.Annotation; import org.eclipse.oomph.base.BasePackage; import org.eclipse.oomph.base.ModelElement; import org.eclipse.oomph.util.ObjectUtil; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; import org.eclipse.emf.ecore.util.InternalEList; import java.lang.reflect.InvocationTargetException; import java.util.Collection; /** * * An implementation of the model object 'Element'. * *

* The following features are implemented: *

* * * @generated */ public abstract class ModelElementImpl extends MinimalEObjectImpl.Container implements ModelElement { /** * The cached value of the '{@link #getAnnotations() Annotations}' containment reference list. * * * @see #getAnnotations() * @generated * @ordered */ protected EList annotations; /** * * * @generated */ protected ModelElementImpl() { super(); } /** * * * @generated */ @Override protected EClass eStaticClass() { return BasePackage.Literals.MODEL_ELEMENT; } /** * * * @generated */ public EList getAnnotations() { if (annotations == null) { annotations = new EObjectContainmentWithInverseEList(Annotation.class, this, BasePackage.MODEL_ELEMENT__ANNOTATIONS, BasePackage.ANNOTATION__MODEL_ELEMENT); } return annotations; } /** * * * @generated NOT */ public Annotation getAnnotation(String source) { for (Annotation annotation : getAnnotations()) { if (ObjectUtil.equals(source, annotation.getSource())) { return annotation; } } return null; } /** * * * @generated */ @SuppressWarnings("unchecked") @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case BasePackage.MODEL_ELEMENT__ANNOTATIONS: return ((InternalEList)(InternalEList)getAnnotations()).basicAdd(otherEnd, msgs); } return super.eInverseAdd(otherEnd, featureID, msgs); } /** * * * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case BasePackage.MODEL_ELEMENT__ANNOTATIONS: return ((InternalEList)getAnnotations()).basicRemove(otherEnd, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * * * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case BasePackage.MODEL_ELEMENT__ANNOTATIONS: return getAnnotations(); } return super.eGet(featureID, resolve, coreType); } /** * * * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case BasePackage.MODEL_ELEMENT__ANNOTATIONS: getAnnotations().clear(); getAnnotations().addAll((Collection)newValue); return; } super.eSet(featureID, newValue); } /** * * * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case BasePackage.MODEL_ELEMENT__ANNOTATIONS: getAnnotations().clear(); return; } super.eUnset(featureID); } /** * * * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case BasePackage.MODEL_ELEMENT__ANNOTATIONS: return annotations != null && !annotations.isEmpty(); } return super.eIsSet(featureID); } /** * * * @generated */ @Override public Object eInvoke(int operationID, EList arguments) throws InvocationTargetException { switch (operationID) { case BasePackage.MODEL_ELEMENT___GET_ANNOTATION__STRING: return getAnnotation((String)arguments.get(0)); } return super.eInvoke(operationID, arguments); } @Override public EObject eObjectForURIFragmentSegment(String uriFragmentSegment) { char firstChar = uriFragmentSegment.charAt(0); if (firstChar == '\'') { int lastIndex = uriFragmentSegment.length() - 1; char lastChar = uriFragmentSegment.charAt(lastIndex); if (lastChar == '\'') { Resource eDirectResource = eDirectResource(); if (eDirectResource != null) { return eDirectResource.getEObject(URI.decode(uriFragmentSegment.substring(1, lastIndex))); } } } return super.eObjectForURIFragmentSegment(uriFragmentSegment); } } // ModelElementImpl