Class FilterComparisonScope
- java.lang.Object
-
- org.eclipse.emf.common.notify.impl.AdapterImpl
-
- org.eclipse.emf.compare.scope.AbstractComparisonScope
-
- org.eclipse.emf.compare.scope.FilterComparisonScope
-
- All Implemented Interfaces:
Adapter
,Adapter.Internal
,IComparisonScope
,IComparisonScope2
,IDiagnosable
- Direct Known Subclasses:
DefaultComparisonScope
public class FilterComparisonScope extends AbstractComparisonScope
This implementation of anIComparisonScope
can be provided specific filters to filter out parts of the Notifiers' content lists.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.emf.common.notify.Adapter
Adapter.Internal
-
-
Field Summary
Fields Modifier and Type Field Description protected com.google.common.base.Predicate<? super EObject>
eObjectContentFilter
This will be used in order to determine the filter that should be used to filter the EObjects' content list of unnecessary values.protected com.google.common.base.Predicate<? super EObject>
resourceContentFilter
This will be used in order to determine the filter that should be used to filter the Resources' content list of unnecessary values.protected com.google.common.base.Predicate<? super Resource>
resourceSetContentFilter
This will be used in order to determine the filter that should be used to filter the ResourceSets' content list of unnecessary values.-
Fields inherited from class org.eclipse.emf.compare.scope.AbstractComparisonScope
allInvolvedResourceURIs, diagnostic, left, nsURIs, origin, resourceURIs, right
-
Fields inherited from class org.eclipse.emf.common.notify.impl.AdapterImpl
target
-
-
Constructor Summary
Constructors Constructor Description FilterComparisonScope(Notifier left, Notifier right, Notifier origin)
This will instantiate a scope with left, right and origin Notifiers defined.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addUri(EObject eObject)
Registers the namespace and resource URI from the giveneObject
.protected void
addUri(Resource resource)
Registers the resource URI from the givenresource
.protected <T> void
addUri(T obj)
Tries and register the URI of the given object as one of this scope's resources.Iterator<? extends EObject>
getChildren(EObject eObject)
This will be used by EMF Compare in order to know which EObjects should be considered to be part of the comparison scope when it is launched on the given EObject.Iterator<? extends EObject>
getCoveredEObjects(Resource resource)
This will be used by EMF Compare in order to determine the EObjects that it should iterate over.Iterator<? extends Resource>
getCoveredResources(ResourceSet resourceSet)
This will be used by EMF Compare in order to determine the Resources that should be considered part of the comparison when it is launched on the given resource set.void
setEObjectContentFilter(com.google.common.base.Predicate<? super EObject> newContentFilter)
This can be used to set the filter that should be used to filter the EObjects' content list of unnecessary values.void
setResourceContentFilter(com.google.common.base.Predicate<? super EObject> resourceContentFilter)
This can be used to set the filter that should be used to filter the Resources' content list of unnecessary values.void
setResourceSetContentFilter(com.google.common.base.Predicate<? super Resource> resourceSetContentFilter)
This can be used to set the filter that should be used to filter the ResourceSets' content list of unnecessary values.-
Methods inherited from class org.eclipse.emf.compare.scope.AbstractComparisonScope
getAllInvolvedResourceURIs, getDiagnostic, getLeft, getNsURIs, getOrigin, getResourceURIs, getRight, isAdapterForType, setDiagnostic
-
Methods inherited from class org.eclipse.emf.common.notify.impl.AdapterImpl
getTarget, notifyChanged, setTarget, unsetTarget
-
-
-
-
Field Detail
-
eObjectContentFilter
protected com.google.common.base.Predicate<? super EObject> eObjectContentFilter
This will be used in order to determine the filter that should be used to filter the EObjects' content list of unnecessary values.
-
resourceContentFilter
protected com.google.common.base.Predicate<? super EObject> resourceContentFilter
This will be used in order to determine the filter that should be used to filter the Resources' content list of unnecessary values.
-
resourceSetContentFilter
protected com.google.common.base.Predicate<? super Resource> resourceSetContentFilter
This will be used in order to determine the filter that should be used to filter the ResourceSets' content list of unnecessary values.
-
-
Constructor Detail
-
FilterComparisonScope
public FilterComparisonScope(Notifier left, Notifier right, Notifier origin)
This will instantiate a scope with left, right and origin Notifiers defined.- Parameters:
left
- The left root of this comparison.right
- The right root of this comparison.origin
- The common ancestor ofleft
andright
. May benull
.
-
-
Method Detail
-
getCoveredResources
public Iterator<? extends Resource> getCoveredResources(ResourceSet resourceSet)
This will be used by EMF Compare in order to determine the Resources that should be considered part of the comparison when it is launched on the given resource set.Do note that this will only be called once per Resource. We will retrieve the set of EMF resources to include in the comparison, match them, then use
IComparisonScope.getCoveredEObjects(Resource)
in order to determine the actual EObjects to cover during that comparison.This default implementation will only return the
Resource
s directly contained byResourceSet
which match theresourceSetContentFilter
predicate.- Parameters:
resourceSet
- The resource set for which we need to know all resources spanned by the comparison.- Returns:
- An iterator over the
Resource
s which are part of this scope. - See Also:
IComparisonScope.getCoveredResources(org.eclipse.emf.ecore.resource.ResourceSet)
-
getCoveredEObjects
public Iterator<? extends EObject> getCoveredEObjects(Resource resource)
This will be used by EMF Compare in order to determine the EObjects that it should iterate over.Do note that this will only be called once per comparison. EMF Compare expects this to return the whole set of EObjects that should be covered by the comparison when launched on the given Resource.
This default implementation will return all direct and indirect content of the given
Resource
, filtering out thoseEObject
s that do not matchresourceContentFilter
.- Parameters:
resource
- The resource for which we need to determine all EObjects spanned by the comparison.- Returns:
- An iterator over the
EObject
s which are part of this scope. - See Also:
IComparisonScope.getCoveredEObjects(org.eclipse.emf.ecore.resource.Resource)
-
getChildren
public Iterator<? extends EObject> getChildren(EObject eObject)
This will be used by EMF Compare in order to know which EObjects should be considered to be part of the comparison scope when it is launched on the given EObject.Do note that this will only be called once per comparison on EObjects, and never for comparisons launched on
ResourceSet
s orResource
s. EMF Compare expects the whole set of EObject that should be covered by the comparison to be returned by this.This default implementation will return all direct and indirect content of the given
EObject
, filtering out thoseEObject
s that do not matcheObjectContentFilter
.- Parameters:
eObject
- The EObject for which we need to determine the comparison scope.- Returns:
- An iterator over the
EObject
s which are part of this scope. - See Also:
IComparisonScope.getChildren(org.eclipse.emf.ecore.EObject)
-
setEObjectContentFilter
public void setEObjectContentFilter(com.google.common.base.Predicate<? super EObject> newContentFilter)
This can be used to set the filter that should be used to filter the EObjects' content list of unnecessary values. By default, we will use an "always true" predicate : the list won't be filtered out unless this is called with a new filter.- Parameters:
newContentFilter
- The filter that should be used for EObject content filtering.
-
setResourceContentFilter
public void setResourceContentFilter(com.google.common.base.Predicate<? super EObject> resourceContentFilter)
This can be used to set the filter that should be used to filter the Resources' content list of unnecessary values. By default, we will return an "always true" predicate : the list won't be filtered out unless this is called with a new filter.- Parameters:
resourceContentFilter
- The filter that should be used for Resource content filtering.
-
setResourceSetContentFilter
public void setResourceSetContentFilter(com.google.common.base.Predicate<? super Resource> resourceSetContentFilter)
This can be used to set the filter that should be used to filter the ResourceSets' content list of unnecessary values. By default, we will return an "always true" predicate : the list won't be filtered out unless this called with a new filter.- Parameters:
resourceSetContentFilter
- The filter that should be used for ResourceSet content filtering.
-
addUri
protected <T> void addUri(T obj)
Tries and register the URI of the given object as one of this scope's resources. Note that we only consider EObjects and Resources.- Type Parameters:
T
- Type of this object.- Parameters:
obj
- eObject for which we
-
addUri
protected void addUri(EObject eObject)
Registers the namespace and resource URI from the giveneObject
.- Parameters:
eObject
- The giveneObject
.
-
addUri
protected void addUri(Resource resource)
Registers the resource URI from the givenresource
.- Parameters:
resource
- The givenresource
.
-
-