/** * Copyright (c) 2012 Obeo. * 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: * Obeo - initial API and implementation */ package org.eclipse.emf.compare.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.compare.ComparePackage; import org.eclipse.emf.compare.Conflict; import org.eclipse.emf.compare.ConflictKind; import org.eclipse.emf.compare.Diff; 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.MinimalEObjectImpl; import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; import org.eclipse.emf.ecore.util.InternalEList; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Conflict</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.eclipse.emf.compare.impl.ConflictImpl#getKind <em>Kind</em>}</li> * <li>{@link org.eclipse.emf.compare.impl.ConflictImpl#getDifferences <em>Differences</em>}</li> * </ul> * </p> * * @generated */ public class ConflictImpl extends MinimalEObjectImpl implements Conflict { /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public static final String copyright = "Copyright (c) 2012 Obeo.\r\nAll rights reserved. This program and the accompanying materials\r\nare made available under the terms of the Eclipse Public License v1.0\r\nwhich accompanies this distribution, and is available at\r\nhttp://www.eclipse.org/legal/epl-v10.html\r\n\r\nContributors:\r\n Obeo - initial API and implementation"; //$NON-NLS-1$ /** * The default value of the '{@link #getKind() <em>Kind</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getKind() * @generated * @ordered */ protected static final ConflictKind KIND_EDEFAULT = ConflictKind.REAL; /** * The cached value of the '{@link #getKind() <em>Kind</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getKind() * @generated * @ordered */ protected ConflictKind kind = KIND_EDEFAULT; /** * The cached value of the '{@link #getDifferences() <em>Differences</em>}' reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getDifferences() * @generated * @ordered */ protected EList<Diff> differences; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected ConflictImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return ComparePackage.Literals.CONFLICT; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public ConflictKind getKind() { return kind; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setKind(ConflictKind newKind) { ConflictKind oldKind = kind; kind = newKind == null ? KIND_EDEFAULT : newKind; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ComparePackage.CONFLICT__KIND, oldKind, kind)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<Diff> getDifferences() { if (differences == null) { differences = new EObjectWithInverseResolvingEList<Diff>(Diff.class, this, ComparePackage.CONFLICT__DIFFERENCES, ComparePackage.DIFF__CONFLICT); } return differences; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<Diff> getLeftDifferences() { // TODO: implement this method // Ensure that you remove @generated or mark it @generated NOT throw new UnsupportedOperationException(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<Diff> getRightDifferences() { // TODO: implement this method // Ensure that you remove @generated or mark it @generated NOT throw new UnsupportedOperationException(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case ComparePackage.CONFLICT__DIFFERENCES: return ((InternalEList<InternalEObject>)(InternalEList<?>)getDifferences()).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 ComparePackage.CONFLICT__DIFFERENCES: return ((InternalEList<?>)getDifferences()).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 ComparePackage.CONFLICT__KIND: return getKind(); case ComparePackage.CONFLICT__DIFFERENCES: return getDifferences(); } 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 ComparePackage.CONFLICT__KIND: setKind((ConflictKind)newValue); return; case ComparePackage.CONFLICT__DIFFERENCES: getDifferences().clear(); getDifferences().addAll((Collection<? extends Diff>)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case ComparePackage.CONFLICT__KIND: setKind(KIND_EDEFAULT); return; case ComparePackage.CONFLICT__DIFFERENCES: getDifferences().clear(); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case ComparePackage.CONFLICT__KIND: return kind != KIND_EDEFAULT; case ComparePackage.CONFLICT__DIFFERENCES: return differences != null && !differences.isEmpty(); } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public String toString() { if (eIsProxy()) return super.toString(); StringBuffer result = new StringBuffer(super.toString()); result.append(" (kind: "); //$NON-NLS-1$ result.append(kind); result.append(')'); return result.toString(); } } //ConflictImpl