public static class EcoreUtil.EqualityHelper extends java.util.HashMap<EObject,EObject>
A helper for determining whether two EObjects are structurally equal.
Two EObjects, eObject1 and eObject2, are structurally equal
if their classes are the same,
and if, for each non-derived feature of the class,
the isSet states are the same
and the corresponding values are structurally equal
as appropriate for the type of feature.
For feature map features,
the entries at corresponding positions
must have the same entry features
and must have structurally equal values
as appropriate for the type of entry's feature.
For reference features,
the corresponding values must recursively be structurally equal according to this definition.
For attribute features,
the corresponding values must be equal according to Java equality.
Note that container references are derived and hence are ignored.
During the recursive process of determining equality,
the helper instance is populated as a two way map
such that a given eObject1 is considered to be equal to at most one other eObject2,
i.e., get(eObject1) == eObject2 && get(eObject2) == eObject1.
While their features are being compared, the two objects are assumed to be equal:
put(eObject1, eObject2); put(eObject2, eObject1);Once that correspondence is established, an
eObject1 considered equal to a different eObject2
will not even be considered equal to itself.
This ensures that two objects are structurally equal only if the graphs formed by all their referenced objects
have the same topology.
| Constructor and Description |
|---|
EqualityHelper() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
equalFeatureMaps(FeatureMap featureMap1,
FeatureMap featureMap2)
Returns whether the two feature maps are
equal. |
protected boolean |
equalFeatureMapValues(java.lang.Object value1,
java.lang.Object value2,
EStructuralFeature feature)
Returns whether the two values of a feature map are
equal. |
boolean |
equals(EObject eObject1,
EObject eObject2)
|
boolean |
equals(java.util.List<EObject> list1,
java.util.List<EObject> list2)
|
protected boolean |
equalValues(java.lang.Object value1,
java.lang.Object value2)
Returns whether value1 and value2 are structurally equal.
|
protected boolean |
haveEqualAttribute(EObject eObject1,
EObject eObject2,
EAttribute attribute)
|
protected boolean |
haveEqualFeature(EObject eObject1,
EObject eObject2,
EStructuralFeature feature)
|
protected boolean |
haveEqualReference(EObject eObject1,
EObject eObject2,
EReference reference)
|
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuespublic boolean equals(EObject eObject1, EObject eObject2)
eObject1 and eObject2 are equal.public boolean equals(java.util.List<EObject> list1, java.util.List<EObject> list2)
list1 and list2 contain
equal EObjects at the same index.
It is assumed that list1 and list2 only contain EObjects.list1 and list2 contain equal objects.protected boolean haveEqualFeature(EObject eObject1, EObject eObject2, EStructuralFeature feature)
equals(EObject, EObject),
equals(List, List)protected boolean haveEqualReference(EObject eObject1, EObject eObject2, EReference reference)
equals(EObject, EObject),
equals(List, List)protected boolean haveEqualAttribute(EObject eObject1, EObject eObject2, EAttribute attribute)
equalFeatureMaps(FeatureMap, FeatureMap)protected boolean equalValues(java.lang.Object value1,
java.lang.Object value2)
value1 - the first non-null value.value2 - the second potentially null value.protected boolean equalFeatureMaps(FeatureMap featureMap1, FeatureMap featureMap2)
equal.protected boolean equalFeatureMapValues(java.lang.Object value1,
java.lang.Object value2,
EStructuralFeature feature)
equal.Copyright © 2018. Licensed under the Eclipse Public License v1.0. All rights reserved.
Submit a bug or feature