| /******************************************************************************* |
| * Copyright (c) 2007, 2010 BMW Car IT, Technische Universitaet Muenchen, and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * BMW Car IT - Initial API and implementation |
| * Technische Universitaet Muenchen - Major refactoring and extension |
| *******************************************************************************/ |
| package org.eclipse.emf.edapt.declaration.impl; |
| |
| import java.util.Collection; |
| |
| 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.EObjectContainmentWithInverseEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| import org.eclipse.emf.edapt.declaration.DeclarationPackage; |
| import org.eclipse.emf.edapt.declaration.Library; |
| import org.eclipse.emf.edapt.declaration.Operation; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Library</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.emf.edapt.declaration.impl.LibraryImpl#getOperations <em>Operations</em>}</li> |
| * <li>{@link org.eclipse.emf.edapt.declaration.impl.LibraryImpl#getImplementation <em>Implementation</em>}</li> |
| * <li>{@link org.eclipse.emf.edapt.declaration.impl.LibraryImpl#getLabel <em>Label</em>}</li> |
| * <li>{@link org.eclipse.emf.edapt.declaration.impl.LibraryImpl#getLibraries <em>Libraries</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class LibraryImpl extends IdentifiedElementImpl implements Library { |
| /** |
| * The cached value of the '{@link #getOperations() <em>Operations</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getOperations() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Operation> operations; |
| |
| /** |
| * The cached value of the '{@link #getImplementation() <em>Implementation</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getImplementation() |
| * @generated |
| * @ordered |
| */ |
| protected Class implementation; |
| |
| /** |
| * The default value of the '{@link #getLabel() <em>Label</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getLabel() |
| * @generated |
| * @ordered |
| */ |
| protected static final String LABEL_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getLabel() <em>Label</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getLabel() |
| * @generated |
| * @ordered |
| */ |
| protected String label = LABEL_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getLibraries() <em>Libraries</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getLibraries() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Library> libraries; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| protected LibraryImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return DeclarationPackage.Literals.LIBRARY; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public EList<Operation> getOperations() { |
| if (operations == null) { |
| operations = new EObjectContainmentWithInverseEList<Operation>(Operation.class, this, |
| DeclarationPackage.LIBRARY__OPERATIONS, DeclarationPackage.OPERATION__LIBRARY); |
| } |
| return operations; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public Class getImplementation() { |
| return implementation; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void setImplementation(Class newImplementation) { |
| final Class oldImplementation = implementation; |
| implementation = newImplementation; |
| if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, Notification.SET, DeclarationPackage.LIBRARY__IMPLEMENTATION, |
| oldImplementation, implementation)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public String getLabel() { |
| return label; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void setLabel(String newLabel) { |
| final String oldLabel = label; |
| label = newLabel; |
| if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, Notification.SET, DeclarationPackage.LIBRARY__LABEL, oldLabel, label)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public EList<Library> getLibraries() { |
| if (libraries == null) { |
| libraries = new EObjectContainmentEList<Library>(Library.class, this, |
| DeclarationPackage.LIBRARY__LIBRARIES); |
| } |
| return libraries; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| @Override |
| public Operation getOperation(String name) { |
| for (final Operation operation : getOperations()) { |
| if (name.equals(operation.getName())) { |
| return operation; |
| } |
| } |
| return null; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case DeclarationPackage.LIBRARY__OPERATIONS: |
| return ((InternalEList<InternalEObject>) (InternalEList<?>) getOperations()).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 DeclarationPackage.LIBRARY__OPERATIONS: |
| return ((InternalEList<?>) getOperations()).basicRemove(otherEnd, msgs); |
| case DeclarationPackage.LIBRARY__LIBRARIES: |
| return ((InternalEList<?>) getLibraries()).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 DeclarationPackage.LIBRARY__OPERATIONS: |
| return getOperations(); |
| case DeclarationPackage.LIBRARY__IMPLEMENTATION: |
| return getImplementation(); |
| case DeclarationPackage.LIBRARY__LABEL: |
| return getLabel(); |
| case DeclarationPackage.LIBRARY__LIBRARIES: |
| return getLibraries(); |
| } |
| 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 DeclarationPackage.LIBRARY__OPERATIONS: |
| getOperations().clear(); |
| getOperations().addAll((Collection<? extends Operation>) newValue); |
| return; |
| case DeclarationPackage.LIBRARY__IMPLEMENTATION: |
| setImplementation((Class) newValue); |
| return; |
| case DeclarationPackage.LIBRARY__LABEL: |
| setLabel((String) newValue); |
| return; |
| case DeclarationPackage.LIBRARY__LIBRARIES: |
| getLibraries().clear(); |
| getLibraries().addAll((Collection<? extends Library>) newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case DeclarationPackage.LIBRARY__OPERATIONS: |
| getOperations().clear(); |
| return; |
| case DeclarationPackage.LIBRARY__IMPLEMENTATION: |
| setImplementation((Class) null); |
| return; |
| case DeclarationPackage.LIBRARY__LABEL: |
| setLabel(LABEL_EDEFAULT); |
| return; |
| case DeclarationPackage.LIBRARY__LIBRARIES: |
| getLibraries().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case DeclarationPackage.LIBRARY__OPERATIONS: |
| return operations != null && !operations.isEmpty(); |
| case DeclarationPackage.LIBRARY__IMPLEMENTATION: |
| return implementation != null; |
| case DeclarationPackage.LIBRARY__LABEL: |
| return LABEL_EDEFAULT == null ? label != null : !LABEL_EDEFAULT.equals(label); |
| case DeclarationPackage.LIBRARY__LIBRARIES: |
| return libraries != null && !libraries.isEmpty(); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) { |
| return super.toString(); |
| } |
| |
| final StringBuffer result = new StringBuffer(super.toString()); |
| result.append(" (implementation: "); //$NON-NLS-1$ |
| result.append(implementation); |
| result.append(", label: "); //$NON-NLS-1$ |
| result.append(label); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } // LibraryImpl |