Class FeatureFilter

java.lang.Object
org.eclipse.emf.compare.diff.FeatureFilter

public class FeatureFilter extends Object
FeatureFilters will be used by the default implementation of a diff engine in order to determine which features it is to check for differences. Any feature that is not returned by this filter will be ignored by the diff engine.

The feature filter will be attached to the comparison once created and its lifecycle will thus be the comparison's. FeatureFilters might be used by later parts of the comparison and merge process. For example, the default conflict detectors will make use of it in order to avoid detecting ordering conflicts on references which ordering is supposed to be ignored. The merge process could use the same in order to determine if it needs to insert elements at the right position in the target lists or just append to the end of these lists.

  • Constructor Details

    • FeatureFilter

      public FeatureFilter()
  • Method Details

    • getReferencesToCheck

      public Iterator<EReference> getReferencesToCheck(Match match)
      The diff engine expects this to return the set of references that need to be checked for differences for the given Match element.

      This default implementation assumes that all three sides of the match are conform to the same metamodel, and simply returns one of the side's side.eClass().getEAllReferences(), ignoring only the derived and container.

      Parameters:
      match - The match for which we are trying to compute differences.
      Returns:
      The set of references that are to be checked by the diff engine. May be an empty iterator, in which case no difference will be detected on any of this match's references.
    • getAttributesToCheck

      public Iterator<EAttribute> getAttributesToCheck(Match match)
      The diff engine expects this to return the set of attributes that need to be checked for differences for the given Match element.

      This default implementation assumes that all three sides of the match are conform to the same metamodel, and simply returns one of the side's side.eClass().getEAllAttributes(), ignoring only the derived.

      Parameters:
      match - The match for which we are trying to compute differences.
      Returns:
      The set of attributes that are to be checked by the diff engine. May be an empty iterator, in which case no difference will be detected on any of this match's attributes.
    • checkForOrderingChanges

      public boolean checkForOrderingChanges(EStructuralFeature feature)
      Tells the diff engine whether the given feature should be checked for changed in the ordering or not. This default implementation considers that any "ordered" or "containment" feature should be checked for changes.
      Parameters:
      feature - The feature we are currently checking.
      Returns:
      true if the diff engine should consider the ordering of this feature, false otherwise.
    • referenceIsSet

      protected boolean referenceIsSet(EReference reference, Match match)
      Checks whether the given reference is set on at least one of the three sides of the given match.
      Parameters:
      reference - The reference we need to be set.
      match - The match for which values we need to check the given reference.
      Returns:
      true if the given reference is set on at least one of the three sides of the given match.
    • isIgnoredReference

      protected boolean isIgnoredReference(Match match, EReference reference)
      This will be used by getReferencesToCheck(Match) in order to determine whether a given reference should be ignored.
      Parameters:
      match - The match from which was taken that particular reference.
      reference - The candidate that might be ignored.
      Returns:
      true if that reference should be ignored by the comparison engine.
    • isIgnoredAttribute

      protected boolean isIgnoredAttribute(EAttribute attribute)
      This will be used by getAttributesToCheck(Match) in order to determine whether a given attribute should be ignored.
      Parameters:
      attribute - The candidate that might be ignored.
      Returns:
      true if that attribute should be ignored by the comparison engine.
    • isTransient

      protected boolean isTransient(EStructuralFeature feature)