/** * Copyright (c) 2012, 2015 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.lang.Iterable; 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.Comparison; import org.eclipse.emf.compare.Diff; import org.eclipse.emf.compare.Match; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; 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.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Match</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.eclipse.emf.compare.impl.MatchImpl#getSubmatches <em>Submatches</em>}</li> * <li>{@link org.eclipse.emf.compare.impl.MatchImpl#getDifferences <em>Differences</em>}</li> * <li>{@link org.eclipse.emf.compare.impl.MatchImpl#getLeft <em>Left</em>}</li> * <li>{@link org.eclipse.emf.compare.impl.MatchImpl#getRight <em>Right</em>}</li> * <li>{@link org.eclipse.emf.compare.impl.MatchImpl#getOrigin <em>Origin</em>}</li> * </ul> * </p> * * @generated */ public class MatchImpl extends MinimalEObjectImpl implements Match { /** * <!-- 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 cached value of the '{@link #getSubmatches() <em>Submatches</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getSubmatches() * @generated * @ordered */ protected EList<Match> submatches; /** * The cached value of the '{@link #getDifferences() <em>Differences</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getDifferences() * @generated * @ordered */ protected EList<Diff> differences; /** * The cached value of the '{@link #getLeft() <em>Left</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getLeft() * @generated * @ordered */ protected EObject left; /** * The cached value of the '{@link #getRight() <em>Right</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getRight() * @generated * @ordered */ protected EObject right; /** * The cached value of the '{@link #getOrigin() <em>Origin</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getOrigin() * @generated * @ordered */ protected EObject origin; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected MatchImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return ComparePackage.Literals.MATCH; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<Match> getSubmatches() { if (submatches == null) { submatches = new EObjectContainmentEList<Match>(Match.class, this, ComparePackage.MATCH__SUBMATCHES); } return submatches; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<Diff> getDifferences() { if (differences == null) { differences = new EObjectContainmentEList<Diff>(Diff.class, this, ComparePackage.MATCH__DIFFERENCES); } return differences; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EObject getLeft() { if (left != null && left.eIsProxy()) { InternalEObject oldLeft = (InternalEObject)left; left = eResolveProxy(oldLeft); if (left != oldLeft) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, ComparePackage.MATCH__LEFT, oldLeft, left)); } } return left; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EObject basicGetLeft() { return left; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setLeft(EObject newLeft) { EObject oldLeft = left; left = newLeft; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ComparePackage.MATCH__LEFT, oldLeft, left)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EObject getRight() { if (right != null && right.eIsProxy()) { InternalEObject oldRight = (InternalEObject)right; right = eResolveProxy(oldRight); if (right != oldRight) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, ComparePackage.MATCH__RIGHT, oldRight, right)); } } return right; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EObject basicGetRight() { return right; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setRight(EObject newRight) { EObject oldRight = right; right = newRight; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ComparePackage.MATCH__RIGHT, oldRight, right)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EObject getOrigin() { if (origin != null && origin.eIsProxy()) { InternalEObject oldOrigin = (InternalEObject)origin; origin = eResolveProxy(oldOrigin); if (origin != oldOrigin) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, ComparePackage.MATCH__ORIGIN, oldOrigin, origin)); } } return origin; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EObject basicGetOrigin() { return origin; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setOrigin(EObject newOrigin) { EObject oldOrigin = origin; origin = newOrigin; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ComparePackage.MATCH__ORIGIN, oldOrigin, origin)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Comparison getComparison() { // 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 Iterable<Match> getAllSubmatches() { // 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 Iterable<Diff> getAllDifferences() { // TODO: implement this method // Ensure that you remove @generated or mark it @generated NOT throw new UnsupportedOperationException(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case ComparePackage.MATCH__SUBMATCHES: return ((InternalEList<?>)getSubmatches()).basicRemove(otherEnd, msgs); case ComparePackage.MATCH__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.MATCH__SUBMATCHES: return getSubmatches(); case ComparePackage.MATCH__DIFFERENCES: return getDifferences(); case ComparePackage.MATCH__LEFT: if (resolve) return getLeft(); return basicGetLeft(); case ComparePackage.MATCH__RIGHT: if (resolve) return getRight(); return basicGetRight(); case ComparePackage.MATCH__ORIGIN: if (resolve) return getOrigin(); return basicGetOrigin(); } 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.MATCH__SUBMATCHES: getSubmatches().clear(); getSubmatches().addAll((Collection<? extends Match>)newValue); return; case ComparePackage.MATCH__DIFFERENCES: getDifferences().clear(); getDifferences().addAll((Collection<? extends Diff>)newValue); return; case ComparePackage.MATCH__LEFT: setLeft((EObject)newValue); return; case ComparePackage.MATCH__RIGHT: setRight((EObject)newValue); return; case ComparePackage.MATCH__ORIGIN: setOrigin((EObject)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case ComparePackage.MATCH__SUBMATCHES: getSubmatches().clear(); return; case ComparePackage.MATCH__DIFFERENCES: getDifferences().clear(); return; case ComparePackage.MATCH__LEFT: setLeft((EObject)null); return; case ComparePackage.MATCH__RIGHT: setRight((EObject)null); return; case ComparePackage.MATCH__ORIGIN: setOrigin((EObject)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case ComparePackage.MATCH__SUBMATCHES: return submatches != null && !submatches.isEmpty(); case ComparePackage.MATCH__DIFFERENCES: return differences != null && !differences.isEmpty(); case ComparePackage.MATCH__LEFT: return left != null; case ComparePackage.MATCH__RIGHT: return right != null; case ComparePackage.MATCH__ORIGIN: return origin != null; } return super.eIsSet(featureID); } } //MatchImpl