| /* |
| * 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 v2.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v20.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; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Element</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.oomph.base.impl.ModelElementImpl#getAnnotations <em>Annotations</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public abstract class ModelElementImpl extends MinimalEObjectImpl.Container implements ModelElement |
| { |
| /** |
| * The cached value of the '{@link #getAnnotations() <em>Annotations</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getAnnotations() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Annotation> annotations; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected ModelElementImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return BasePackage.Literals.MODEL_ELEMENT; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Annotation> getAnnotations() |
| { |
| if (annotations == null) |
| { |
| annotations = new EObjectContainmentWithInverseEList<Annotation>(Annotation.class, this, BasePackage.MODEL_ELEMENT__ANNOTATIONS, |
| BasePackage.ANNOTATION__MODEL_ELEMENT); |
| } |
| return annotations; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public Annotation getAnnotation(String source) |
| { |
| for (Annotation annotation : getAnnotations()) |
| { |
| if (ObjectUtil.equals(source, annotation.getSource())) |
| { |
| return annotation; |
| } |
| } |
| |
| return null; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case BasePackage.MODEL_ELEMENT__ANNOTATIONS: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getAnnotations()).basicAdd(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 BasePackage.MODEL_ELEMENT__ANNOTATIONS: |
| return ((InternalEList<?>)getAnnotations()).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 BasePackage.MODEL_ELEMENT__ANNOTATIONS: |
| return getAnnotations(); |
| } |
| 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 BasePackage.MODEL_ELEMENT__ANNOTATIONS: |
| getAnnotations().clear(); |
| getAnnotations().addAll((Collection<? extends Annotation>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case BasePackage.MODEL_ELEMENT__ANNOTATIONS: |
| getAnnotations().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case BasePackage.MODEL_ELEMENT__ANNOTATIONS: |
| return annotations != null && !annotations.isEmpty(); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @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 |