org.eclipse.emf.ecore.util
Class EcoreUtil.EqualityHelper

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended byorg.eclipse.emf.ecore.util.EcoreUtil.EqualityHelper
All Implemented Interfaces:
Cloneable, Map, Serializable
Enclosing class:
EcoreUtil

public static class EcoreUtil.EqualityHelper
extends HashMap

A helper for determining whether two eObjects are equal.

Two EObjects are (deep-)equal if they are shallow-equal, and all their references, except the one to their container, are equal.
Two eObject are shallow-equal if they have the same eClass, and their attributes are equal.
Two attributes are equal if they are both not set, or set to an equal value.
Two references are equal if they are both not set, or all the eObjects they refer to are equal in the context of eObject1 and eObject2.
Note that container references are not compared, which means two eObjects can be equal even if their container is not equal.

An eObject directly or indirectly referenced by eObject1 or eObject2 can only be equal to exactly one eObject directly or indirectly referenced by eObject2 or eObject1, respectively. This ensures that eObject1 and eObject2 are equal if the graphs formed by all their referenced eObjects have the same shape (eObject1 and eObject2 are structurally-equal). For example, it is possible that two eObjects referenced by eObject1 and eObject2 refer to the same (==) eObject but are not equal because the eObject they refer to is already shallow-equal to another eObject.

Use EcoreUtil#equal(EObject, EObject) to determine whether two eObjects are equal.

EqualityHelper is a Map that contains all the eObjects that have already been found to be shallow-equal since it has been instantiated.

See Also:
Serialized Form

Constructor Summary
EcoreUtil.EqualityHelper()
           
 
Method Summary
protected  boolean equals(EObject eObject1, EObject eObject2)
           
protected  boolean equals(List list1, List list2)
           
protected  boolean haveEqualAttribute(EObject eObject1, EObject eObject2, EAttribute attribute)
           
protected  boolean haveEqualAttributes(EObject eObject1, EObject eObject2)
           
protected  boolean haveEqualFeatureMap(EObject eObject1, EObject eObject2, FeatureMap featureMap1, FeatureMap featureMap2)
           
protected  boolean haveEqualReference(EObject eObject1, EObject eObject2, EReference reference)
           
protected  boolean haveEqualReferences(EObject eObject1, EObject eObject2)
           
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

EcoreUtil.EqualityHelper

public EcoreUtil.EqualityHelper()
Method Detail

equals

protected boolean equals(EObject eObject1,
                         EObject eObject2)
Returns:
true if eObject1 and eObject2 are equal in the context of this instance of EqualityHelper, false otherwise. Refer to EcoreUtil.EqualityHelper for the definition of EObject equality.
Since:
2.1.0

haveEqualAttributes

protected boolean haveEqualAttributes(EObject eObject1,
                                      EObject eObject2)
Returns:
true if attributes are not set or set to the same value for eObject1 and eObject2, false otherwise. (It is assumed that eObject1 and eObject2 have the same EClass.)
Since:
2.1.0

haveEqualAttribute

protected boolean haveEqualAttribute(EObject eObject1,
                                     EObject eObject2,
                                     EAttribute attribute)
Returns:
true if attribute is not set or set to the same value for eObject1 and eObject2, false otherwise. (It is assumed that attribute is part of eObject1 and eObject2's attributes.)
Since:
2.1.0

haveEqualFeatureMap

protected boolean haveEqualFeatureMap(EObject eObject1,
                                      EObject eObject2,
                                      FeatureMap featureMap1,
                                      FeatureMap featureMap2)
Returns:
true if featureMap1 and featureMap2 are equal.
Since:
2.1.0

haveEqualReferences

protected boolean haveEqualReferences(EObject eObject1,
                                      EObject eObject2)
Returns:
true if refrences are not set or refer to equal EObjects for eObject1 and eObject2 are equal, false otherwise. (It is assumed that eObject1 and eObject2 have the same EClass.)
Since:
2.1.0

haveEqualReference

protected boolean haveEqualReference(EObject eObject1,
                                     EObject eObject2,
                                     EReference reference)
Returns:
true if reference is not set or set to equal EObjects for eObject1 and eObject2, false otherwise. (It is assumed that reference is part of eObject1 and eObject2's references.)
Since:
2.1.0

equals

protected boolean equals(List list1,
                         List list2)
Returns:
true if list1 and list2 contain equal EObjects at the same index. (It is assumed that list1 and list2 only contain EObjects.)
Since:
2.1.0

Copyright 2001-2004 IBM Corporation and others.
All Rights Reserved.