Package org.eclipse.emf.compare.utils
Class EqualityHelper
- java.lang.Object
-
- org.eclipse.emf.common.notify.impl.AdapterImpl
-
- org.eclipse.emf.compare.utils.EqualityHelper
-
- All Implemented Interfaces:
Adapter,Adapter.Internal,IEqualityHelper
public class EqualityHelper extends AdapterImpl implements IEqualityHelper
EMF Compare needs its own rules for "equality", which are based on similarity instead of strict equality. These will be used throughout the process.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.emf.common.notify.Adapter
Adapter.Internal
-
-
Field Summary
-
Fields inherited from class org.eclipse.emf.common.notify.impl.AdapterImpl
target
-
-
Constructor Summary
Constructors Constructor Description EqualityHelper()Deprecated.use the EqualityHelper(Cache) constructor instead.EqualityHelper(com.google.common.cache.LoadingCache<EObject,URI> uriCache)Creates a new EqualityHelper with the given cache.EqualityHelper(com.google.common.cache.LoadingCache<EObject,URI> uriCache, EqualityHelperExtensionProvider.Descriptor.Registry equalityHelperExtensionProviderRegistry)Creates a new EqualityHelper with the given cache and registry.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static com.google.common.cache.LoadingCache<EObject,URI>createDefaultCache(com.google.common.cache.CacheBuilder<Object,Object> cacheBuilder)Create a cache as required by EqualityHelper.com.google.common.cache.Cache<EObject,URI>getCache()Deprecated.protected MatchgetMatch(EObject o)Returns the match of this EObject if any,nullotherwise.ComparisongetTarget()URIgetURI(EObject object)Deprecated.booleanisAdapterForType(Object type)booleanmatchingAttributeValues(Object object1, Object object2)This should only be used if the two given Objects are known not to be instances of EObjects.protected booleanmatchingEObjects(EObject object1, EObject object2)Compares two values as EObjects, using their Match if it can be found, comparing through their URIs otherwise.protected booleanmatchingURIs(EObject object1, EObject object2)Compare the URIs (of similar concept) of EObjects.booleanmatchingValues(Object object1, Object object2)Check that the two given values are "equal", considering the specifics of EMF.booleanmatchingValues(Comparison comparison, Object object1, Object object2)Deprecated.voidsetTarget(Notifier newTarget)-
Methods inherited from class org.eclipse.emf.common.notify.impl.AdapterImpl
notifyChanged, unsetTarget
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.emf.common.notify.Adapter
notifyChanged
-
-
-
-
Constructor Detail
-
EqualityHelper
@Deprecated public EqualityHelper()
Deprecated.use the EqualityHelper(Cache) constructor instead.Creates a new EqualityHelper.
-
EqualityHelper
public EqualityHelper(com.google.common.cache.LoadingCache<EObject,URI> uriCache)
Creates a new EqualityHelper with the given cache.- Parameters:
uriCache- the cache to be used forEcoreUtil.getURI(EObject)calls.
-
EqualityHelper
public EqualityHelper(com.google.common.cache.LoadingCache<EObject,URI> uriCache, EqualityHelperExtensionProvider.Descriptor.Registry equalityHelperExtensionProviderRegistry)
Creates a new EqualityHelper with the given cache and registry.- Parameters:
uriCache- the cache to be used forEcoreUtil.getURI(EObject)calls.equalityHelperExtensionProviderRegistry- Registry ofequality helper extension provider
-
-
Method Detail
-
getTarget
public Comparison getTarget()
- Specified by:
getTargetin interfaceAdapter- Specified by:
getTargetin interfaceIEqualityHelper- Overrides:
getTargetin classAdapterImpl- See Also:
AdapterImpl.getTarget()
-
setTarget
public void setTarget(Notifier newTarget)
- Specified by:
setTargetin interfaceAdapter- Overrides:
setTargetin classAdapterImpl- See Also:
AdapterImpl.setTarget(Notifier)
-
isAdapterForType
public boolean isAdapterForType(Object type)
- Specified by:
isAdapterForTypein interfaceAdapter- Overrides:
isAdapterForTypein classAdapterImpl- See Also:
AdapterImpl.isAdapterForType(java.lang.Object)
-
matchingValues
@Deprecated public boolean matchingValues(Comparison comparison, Object object1, Object object2)
Deprecated.Check that the two given values are "equal", considering the specifics of EMF.- Parameters:
comparison- Provides us with the Match necessary for EObject comparison.object1- First of the two objects to compare here.object2- Second of the two objects to compare here.- Returns:
trueif both objects are to be considered equal,falseotherwise.- See Also:
matchingValues(Object, Object)
-
matchingValues
public boolean matchingValues(Object object1, Object object2)
Check that the two given values are "equal", considering the specifics of EMF.- Specified by:
matchingValuesin interfaceIEqualityHelper- Parameters:
object1- First of the two objects to compare here.object2- Second of the two objects to compare here.- Returns:
trueif both objects are to be considered equal,falseotherwise.- See Also:
IEqualityHelper.matchingValues(java.lang.Object, java.lang.Object)
-
matchingEObjects
protected boolean matchingEObjects(EObject object1, EObject object2)
Compares two values as EObjects, using their Match if it can be found, comparing through their URIs otherwise.- Parameters:
object1- First of the two objects to compare here.object2- Second of the two objects to compare here.- Returns:
trueif these two EObjects are to be considered equal,falseotherwise.
-
getMatch
protected Match getMatch(EObject o)
Returns the match of this EObject if any,nullotherwise.- Parameters:
o- The object for which we need the associated Match.- Returns:
- Match of this EObject if any,
nullotherwise.
-
matchingURIs
protected boolean matchingURIs(EObject object1, EObject object2)
Compare the URIs (of similar concept) of EObjects.- Parameters:
object1- First of the two objects to compare here.object2- Second of the two objects to compare here.- Returns:
trueif these two EObjects have the same URIs,falseotherwise.
-
matchingAttributeValues
public boolean matchingAttributeValues(Object object1, Object object2)
This should only be used if the two given Objects are known not to be instances of EObjects. EObjects passed for comparison through here will be compared through theirObject.equals(Object)implementation.- Specified by:
matchingAttributeValuesin interfaceIEqualityHelper- Parameters:
object1- First of the two objects to compare here.object2- Second of the two objects to compare here.- Returns:
trueif both objects are to be considered equal,falseotherwise.- See Also:
IEqualityHelper.matchingAttributeValues(java.lang.Object, java.lang.Object)
-
getURI
@Deprecated public URI getURI(EObject object)
Deprecated.The EqualityHelper often needs to get an EObject uri. As such it has an internal cache that clients might leverage through this method.- Parameters:
object- any EObject.- Returns:
- the URI of the given EObject, or
nullif we somehow could not compute it.
-
getCache
@Deprecated public com.google.common.cache.Cache<EObject,URI> getCache()
Deprecated.Returns the cache used by this object.- Returns:
- the cache used by this object.
-
createDefaultCache
public static com.google.common.cache.LoadingCache<EObject,URI> createDefaultCache(com.google.common.cache.CacheBuilder<Object,Object> cacheBuilder)
Create a cache as required by EqualityHelper.- Parameters:
cacheBuilder- The builder to use to instantiate the cache.- Returns:
- the new cache.
-
-