| /******************************************************************************* |
| * 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.spi.history.impl; |
| |
| import java.util.Collection; |
| import java.util.Date; |
| |
| 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.impl.EObjectImpl; |
| import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
| import org.eclipse.emf.ecore.util.EcoreUtil; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| import org.eclipse.emf.edapt.spi.history.Change; |
| import org.eclipse.emf.edapt.spi.history.History; |
| import org.eclipse.emf.edapt.spi.history.HistoryPackage; |
| import org.eclipse.emf.edapt.spi.history.Release; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Release</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.emf.edapt.spi.history.impl.ReleaseImpl#getDate <em>Date</em>}</li> |
| * <li>{@link org.eclipse.emf.edapt.spi.history.impl.ReleaseImpl#getChanges <em>Changes</em>}</li> |
| * <li>{@link org.eclipse.emf.edapt.spi.history.impl.ReleaseImpl#getHistory <em>History</em>}</li> |
| * <li>{@link org.eclipse.emf.edapt.spi.history.impl.ReleaseImpl#getLabel <em>Label</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class ReleaseImpl extends EObjectImpl implements Release { |
| /** |
| * The default value of the '{@link #getDate() <em>Date</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getDate() |
| * @generated |
| * @ordered |
| */ |
| protected static final Date DATE_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getDate() <em>Date</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getDate() |
| * @generated |
| * @ordered |
| */ |
| protected Date date = DATE_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getChanges() <em>Changes</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getChanges() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Change> changes; |
| |
| /** |
| * 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; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| protected ReleaseImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return HistoryPackage.Literals.RELEASE; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| @Override |
| public int getNumber() { |
| return getHistory().getReleases().indexOf(this); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| @Override |
| public boolean isLatestRelease() { |
| return getHistory().getLatestRelease() == this; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public Date getDate() { |
| return date; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void setDate(Date newDate) { |
| final Date oldDate = date; |
| date = newDate; |
| if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, Notification.SET, HistoryPackage.RELEASE__DATE, oldDate, date)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public EList<Change> getChanges() { |
| if (changes == null) { |
| changes = new EObjectContainmentEList<Change>(Change.class, this, HistoryPackage.RELEASE__CHANGES); |
| } |
| return changes; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public History getHistory() { |
| if (eContainerFeatureID() != HistoryPackage.RELEASE__HISTORY) { |
| return null; |
| } |
| return (History) eContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public NotificationChain basicSetHistory(History newHistory, NotificationChain msgs) { |
| msgs = eBasicSetContainer((InternalEObject) newHistory, HistoryPackage.RELEASE__HISTORY, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void setHistory(History newHistory) { |
| if (newHistory != eInternalContainer() |
| || eContainerFeatureID() != HistoryPackage.RELEASE__HISTORY && newHistory != null) { |
| if (EcoreUtil.isAncestor(this, newHistory)) { |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$ |
| } |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) { |
| msgs = eBasicRemoveFromContainer(msgs); |
| } |
| if (newHistory != null) { |
| msgs = ((InternalEObject) newHistory).eInverseAdd(this, HistoryPackage.HISTORY__RELEASES, |
| History.class, msgs); |
| } |
| msgs = basicSetHistory(newHistory, msgs); |
| if (msgs != null) { |
| msgs.dispatch(); |
| } |
| } |
| else if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, Notification.SET, HistoryPackage.RELEASE__HISTORY, newHistory, |
| newHistory)); |
| } |
| } |
| |
| /** |
| * <!-- 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, HistoryPackage.RELEASE__LABEL, oldLabel, label)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| @Override |
| public Release getNextRelease() { |
| if (isLastRelease()) { |
| return null; |
| } |
| return getHistory().getReleases().get(getNumber() + 1); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| @Override |
| public Release getPreviousRelease() { |
| if (isFirstRelease()) { |
| return null; |
| } |
| return getHistory().getReleases().get(getNumber() - 1); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| @Override |
| public boolean isFirstRelease() { |
| return getHistory().getFirstRelease() == this; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| @Override |
| public boolean isLastRelease() { |
| return getHistory().getLastRelease() == this; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case HistoryPackage.RELEASE__HISTORY: |
| if (eInternalContainer() != null) { |
| msgs = eBasicRemoveFromContainer(msgs); |
| } |
| return basicSetHistory((History) 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 HistoryPackage.RELEASE__CHANGES: |
| return ((InternalEList<?>) getChanges()).basicRemove(otherEnd, msgs); |
| case HistoryPackage.RELEASE__HISTORY: |
| return basicSetHistory(null, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| switch (eContainerFeatureID()) { |
| case HistoryPackage.RELEASE__HISTORY: |
| return eInternalContainer().eInverseRemove(this, HistoryPackage.HISTORY__RELEASES, History.class, msgs); |
| } |
| return super.eBasicRemoveFromContainerFeature(msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case HistoryPackage.RELEASE__DATE: |
| return getDate(); |
| case HistoryPackage.RELEASE__CHANGES: |
| return getChanges(); |
| case HistoryPackage.RELEASE__HISTORY: |
| return getHistory(); |
| case HistoryPackage.RELEASE__LABEL: |
| return getLabel(); |
| } |
| 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 HistoryPackage.RELEASE__DATE: |
| setDate((Date) newValue); |
| return; |
| case HistoryPackage.RELEASE__CHANGES: |
| getChanges().clear(); |
| getChanges().addAll((Collection<? extends Change>) newValue); |
| return; |
| case HistoryPackage.RELEASE__HISTORY: |
| setHistory((History) newValue); |
| return; |
| case HistoryPackage.RELEASE__LABEL: |
| setLabel((String) newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case HistoryPackage.RELEASE__DATE: |
| setDate(DATE_EDEFAULT); |
| return; |
| case HistoryPackage.RELEASE__CHANGES: |
| getChanges().clear(); |
| return; |
| case HistoryPackage.RELEASE__HISTORY: |
| setHistory((History) null); |
| return; |
| case HistoryPackage.RELEASE__LABEL: |
| setLabel(LABEL_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case HistoryPackage.RELEASE__DATE: |
| return DATE_EDEFAULT == null ? date != null : !DATE_EDEFAULT.equals(date); |
| case HistoryPackage.RELEASE__CHANGES: |
| return changes != null && !changes.isEmpty(); |
| case HistoryPackage.RELEASE__HISTORY: |
| return getHistory() != null; |
| case HistoryPackage.RELEASE__LABEL: |
| return LABEL_EDEFAULT == null ? label != null : !LABEL_EDEFAULT.equals(label); |
| } |
| 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(" (date: "); //$NON-NLS-1$ |
| result.append(date); |
| result.append(", label: "); //$NON-NLS-1$ |
| result.append(label); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } // ReleaseImpl |