2 * Copyright (c) 2012, 2015 Obeo.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Obeo - initial API and implementation
11 package org
.eclipse
.emf
.compare
.impl
;
13 import java
.lang
.Iterable
;
14 import java
.util
.Collection
;
16 import org
.eclipse
.emf
.common
.notify
.Notification
;
17 import org
.eclipse
.emf
.common
.notify
.NotificationChain
;
19 import org
.eclipse
.emf
.common
.util
.EList
;
21 import org
.eclipse
.emf
.compare
.ComparePackage
;
22 import org
.eclipse
.emf
.compare
.Comparison
;
23 import org
.eclipse
.emf
.compare
.Diff
;
24 import org
.eclipse
.emf
.compare
.Match
;
26 import org
.eclipse
.emf
.ecore
.EClass
;
27 import org
.eclipse
.emf
.ecore
.EObject
;
28 import org
.eclipse
.emf
.ecore
.InternalEObject
;
30 import org
.eclipse
.emf
.ecore
.impl
.ENotificationImpl
;
31 import org
.eclipse
.emf
.ecore
.impl
.MinimalEObjectImpl
;
33 import org
.eclipse
.emf
.ecore
.util
.EObjectContainmentEList
;
34 import org
.eclipse
.emf
.ecore
.util
.InternalEList
;
37 * <!-- begin-user-doc -->
38 * An implementation of the model object '<em><b>Match</b></em>'.
39 * <!-- end-user-doc -->
41 * The following features are implemented:
43 * <li>{@link org.eclipse.emf.compare.impl.MatchImpl#getSubmatches <em>Submatches</em>}</li>
44 * <li>{@link org.eclipse.emf.compare.impl.MatchImpl#getDifferences <em>Differences</em>}</li>
45 * <li>{@link org.eclipse.emf.compare.impl.MatchImpl#getLeft <em>Left</em>}</li>
46 * <li>{@link org.eclipse.emf.compare.impl.MatchImpl#getRight <em>Right</em>}</li>
47 * <li>{@link org.eclipse.emf.compare.impl.MatchImpl#getOrigin <em>Origin</em>}</li>
53 public class MatchImpl
extends MinimalEObjectImpl
implements Match
{
55 * <!-- begin-user-doc -->
56 * <!-- end-user-doc -->
59 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$
62 * The cached value of the '{@link #getSubmatches() <em>Submatches</em>}' containment reference list.
63 * <!-- begin-user-doc -->
64 * <!-- end-user-doc -->
65 * @see #getSubmatches()
69 protected EList
<Match
> submatches
;
72 * The cached value of the '{@link #getDifferences() <em>Differences</em>}' containment reference list.
73 * <!-- begin-user-doc -->
74 * <!-- end-user-doc -->
75 * @see #getDifferences()
79 protected EList
<Diff
> differences
;
82 * The cached value of the '{@link #getLeft() <em>Left</em>}' reference.
83 * <!-- begin-user-doc -->
84 * <!-- end-user-doc -->
89 protected EObject left
;
92 * The cached value of the '{@link #getRight() <em>Right</em>}' reference.
93 * <!-- begin-user-doc -->
94 * <!-- end-user-doc -->
99 protected EObject right
;
102 * The cached value of the '{@link #getOrigin() <em>Origin</em>}' reference.
103 * <!-- begin-user-doc -->
104 * <!-- end-user-doc -->
109 protected EObject origin
;
112 * <!-- begin-user-doc -->
113 * <!-- end-user-doc -->
116 protected MatchImpl() {
121 * <!-- begin-user-doc -->
122 * <!-- end-user-doc -->
126 protected EClass
eStaticClass() {
127 return ComparePackage
.Literals
.MATCH
;
131 * <!-- begin-user-doc -->
132 * <!-- end-user-doc -->
135 public EList
<Match
> getSubmatches() {
136 if (submatches
== null) {
137 submatches
= new EObjectContainmentEList
<Match
>(Match
.class, this,
138 ComparePackage
.MATCH__SUBMATCHES
);
144 * <!-- begin-user-doc -->
145 * <!-- end-user-doc -->
148 public EList
<Diff
> getDifferences() {
149 if (differences
== null) {
150 differences
= new EObjectContainmentEList
<Diff
>(Diff
.class, this,
151 ComparePackage
.MATCH__DIFFERENCES
);
157 * <!-- begin-user-doc -->
158 * <!-- end-user-doc -->
161 public EObject
getLeft() {
162 if (left
!= null && left
.eIsProxy()) {
163 InternalEObject oldLeft
= (InternalEObject
)left
;
164 left
= eResolveProxy(oldLeft
);
165 if (left
!= oldLeft
) {
166 if (eNotificationRequired())
167 eNotify(new ENotificationImpl(this, Notification
.RESOLVE
, ComparePackage
.MATCH__LEFT
,
175 * <!-- begin-user-doc -->
176 * <!-- end-user-doc -->
179 public EObject
basicGetLeft() {
184 * <!-- begin-user-doc -->
185 * <!-- end-user-doc -->
188 public void setLeft(EObject newLeft
) {
189 EObject oldLeft
= left
;
191 if (eNotificationRequired())
192 eNotify(new ENotificationImpl(this, Notification
.SET
, ComparePackage
.MATCH__LEFT
, oldLeft
, left
));
196 * <!-- begin-user-doc -->
197 * <!-- end-user-doc -->
200 public EObject
getRight() {
201 if (right
!= null && right
.eIsProxy()) {
202 InternalEObject oldRight
= (InternalEObject
)right
;
203 right
= eResolveProxy(oldRight
);
204 if (right
!= oldRight
) {
205 if (eNotificationRequired())
206 eNotify(new ENotificationImpl(this, Notification
.RESOLVE
, ComparePackage
.MATCH__RIGHT
,
214 * <!-- begin-user-doc -->
215 * <!-- end-user-doc -->
218 public EObject
basicGetRight() {
223 * <!-- begin-user-doc -->
224 * <!-- end-user-doc -->
227 public void setRight(EObject newRight
) {
228 EObject oldRight
= right
;
230 if (eNotificationRequired())
231 eNotify(new ENotificationImpl(this, Notification
.SET
, ComparePackage
.MATCH__RIGHT
, oldRight
,
236 * <!-- begin-user-doc -->
237 * <!-- end-user-doc -->
240 public EObject
getOrigin() {
241 if (origin
!= null && origin
.eIsProxy()) {
242 InternalEObject oldOrigin
= (InternalEObject
)origin
;
243 origin
= eResolveProxy(oldOrigin
);
244 if (origin
!= oldOrigin
) {
245 if (eNotificationRequired())
246 eNotify(new ENotificationImpl(this, Notification
.RESOLVE
, ComparePackage
.MATCH__ORIGIN
,
254 * <!-- begin-user-doc -->
255 * <!-- end-user-doc -->
258 public EObject
basicGetOrigin() {
263 * <!-- begin-user-doc -->
264 * <!-- end-user-doc -->
267 public void setOrigin(EObject newOrigin
) {
268 EObject oldOrigin
= origin
;
270 if (eNotificationRequired())
271 eNotify(new ENotificationImpl(this, Notification
.SET
, ComparePackage
.MATCH__ORIGIN
, oldOrigin
,
276 * <!-- begin-user-doc -->
277 * <!-- end-user-doc -->
280 public Comparison
getComparison() {
281 // TODO: implement this method
282 // Ensure that you remove @generated or mark it @generated NOT
283 throw new UnsupportedOperationException();
287 * <!-- begin-user-doc -->
288 * <!-- end-user-doc -->
291 public Iterable
<Match
> getAllSubmatches() {
292 // TODO: implement this method
293 // Ensure that you remove @generated or mark it @generated NOT
294 throw new UnsupportedOperationException();
298 * <!-- begin-user-doc -->
299 * <!-- end-user-doc -->
302 public Iterable
<Diff
> getAllDifferences() {
303 // TODO: implement this method
304 // Ensure that you remove @generated or mark it @generated NOT
305 throw new UnsupportedOperationException();
309 * <!-- begin-user-doc -->
310 * <!-- end-user-doc -->
314 public NotificationChain
eInverseRemove(InternalEObject otherEnd
, int featureID
, NotificationChain msgs
) {
316 case ComparePackage
.MATCH__SUBMATCHES
:
317 return ((InternalEList
<?
>)getSubmatches()).basicRemove(otherEnd
, msgs
);
318 case ComparePackage
.MATCH__DIFFERENCES
:
319 return ((InternalEList
<?
>)getDifferences()).basicRemove(otherEnd
, msgs
);
321 return super.eInverseRemove(otherEnd
, featureID
, msgs
);
325 * <!-- begin-user-doc -->
326 * <!-- end-user-doc -->
330 public Object
eGet(int featureID
, boolean resolve
, boolean coreType
) {
332 case ComparePackage
.MATCH__SUBMATCHES
:
333 return getSubmatches();
334 case ComparePackage
.MATCH__DIFFERENCES
:
335 return getDifferences();
336 case ComparePackage
.MATCH__LEFT
:
339 return basicGetLeft();
340 case ComparePackage
.MATCH__RIGHT
:
343 return basicGetRight();
344 case ComparePackage
.MATCH__ORIGIN
:
347 return basicGetOrigin();
349 return super.eGet(featureID
, resolve
, coreType
);
353 * <!-- begin-user-doc -->
354 * <!-- end-user-doc -->
357 @SuppressWarnings("unchecked")
359 public void eSet(int featureID
, Object newValue
) {
361 case ComparePackage
.MATCH__SUBMATCHES
:
362 getSubmatches().clear();
363 getSubmatches().addAll((Collection
<?
extends Match
>)newValue
);
365 case ComparePackage
.MATCH__DIFFERENCES
:
366 getDifferences().clear();
367 getDifferences().addAll((Collection
<?
extends Diff
>)newValue
);
369 case ComparePackage
.MATCH__LEFT
:
370 setLeft((EObject
)newValue
);
372 case ComparePackage
.MATCH__RIGHT
:
373 setRight((EObject
)newValue
);
375 case ComparePackage
.MATCH__ORIGIN
:
376 setOrigin((EObject
)newValue
);
379 super.eSet(featureID
, newValue
);
383 * <!-- begin-user-doc -->
384 * <!-- end-user-doc -->
388 public void eUnset(int featureID
) {
390 case ComparePackage
.MATCH__SUBMATCHES
:
391 getSubmatches().clear();
393 case ComparePackage
.MATCH__DIFFERENCES
:
394 getDifferences().clear();
396 case ComparePackage
.MATCH__LEFT
:
397 setLeft((EObject
)null);
399 case ComparePackage
.MATCH__RIGHT
:
400 setRight((EObject
)null);
402 case ComparePackage
.MATCH__ORIGIN
:
403 setOrigin((EObject
)null);
406 super.eUnset(featureID
);
410 * <!-- begin-user-doc -->
411 * <!-- end-user-doc -->
415 public boolean eIsSet(int featureID
) {
417 case ComparePackage
.MATCH__SUBMATCHES
:
418 return submatches
!= null && !submatches
.isEmpty();
419 case ComparePackage
.MATCH__DIFFERENCES
:
420 return differences
!= null && !differences
.isEmpty();
421 case ComparePackage
.MATCH__LEFT
:
423 case ComparePackage
.MATCH__RIGHT
:
424 return right
!= null;
425 case ComparePackage
.MATCH__ORIGIN
:
426 return origin
!= null;
428 return super.eIsSet(featureID
);