Class AbstractElementsTreeMatcher

java.lang.Object
com._1c.g5.v8.dt.compare.matching.AbstractElementsTreeMatcher
All Implemented Interfaces:
IElementsTreeMatcher
Direct Known Subclasses:
FormElementsMatcher, PredefinedMdObjectMatcher

public abstract class AbstractElementsTreeMatcher extends Object implements IElementsTreeMatcher
Abstract implementation of matcher of elements tree.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractElementsTreeMatcher(IComparisonSession session, MergeRule mergeRule, org.eclipse.emf.ecore.EObject main, org.eclipse.emf.ecore.EObject other, org.eclipse.emf.ecore.EObject ancestor)
    Creates matcher instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final ComparedObjectPath
    buildPath(ComparedObjectPath parentPath, org.eclipse.emf.ecore.EObject matchedObject, org.eclipse.emf.ecore.EStructuralFeature feature)
    Builds path for the specified single feature.
    protected final ComparedObjectPath
    buildPath(ComparedObjectPath parentPath, org.eclipse.emf.ecore.EObject matchedObject, org.eclipse.emf.ecore.EStructuralFeature feature, int position)
    Builds path for the specified many-feature.
    protected abstract Object
    createItemId(org.eclipse.emf.ecore.EObject item)
    Creates unique identifier of the given item.
    protected final Object
    createItemId(org.eclipse.emf.ecore.EObject main, org.eclipse.emf.ecore.EObject other, org.eclipse.emf.ecore.EObject ancestor)
    Creates unique identifier for elements matched earlier.
    getMatchedChildren(org.eclipse.emf.ecore.EObject main, org.eclipse.emf.ecore.EObject other, org.eclipse.emf.ecore.EObject ancestor)
    Returns children (without sub-children) of the given elements in a result matched tree.
    getMatchedElement(org.eclipse.emf.ecore.EObject forItem)
    Returns matched compared element for the given input element.
    protected abstract ComparedObjectPath
    getRootPath(org.eclipse.emf.ecore.EObject rootItem)
    Returns the path for the root item.
    protected abstract void
    matchElements(org.eclipse.emf.ecore.EObject container, ComparedObjectPath containerPath, ComparisonSide side)
    Matches child items of the given container and puts them by calling #putElement(EObject, ComparisonSide) method.
    protected void
    putMatchedElement(org.eclipse.emf.ecore.EObject item, ComparedObjectPath path, ComparisonSide side)
    Stores matched element for the given comparison side.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractElementsTreeMatcher

      protected AbstractElementsTreeMatcher(IComparisonSession session, MergeRule mergeRule, org.eclipse.emf.ecore.EObject main, org.eclipse.emf.ecore.EObject other, org.eclipse.emf.ecore.EObject ancestor)
      Creates matcher instance. At least one of input elements must not be null.
      Parameters:
      session - the comparison session, cannot be null
      mergeRule - the merge rule to apply when merging elements tree, cannot be null
      main - main element to compare
      other - other element to compare
      ancestor - ancestor element to compare
  • Method Details

    • getMatchedElement

      public MatchedEmfObjects getMatchedElement(org.eclipse.emf.ecore.EObject forItem)
      Description copied from interface: IElementsTreeMatcher
      Returns matched compared element for the given input element.
      Specified by:
      getMatchedElement in interface IElementsTreeMatcher
      Parameters:
      forItem - the element from any of trees (main/other/ancestor) for which to get the compared element
      Returns:
      compared element found or null if the given input element is not matched
    • getMatchedChildren

      public List<MatchedEmfObjects> getMatchedChildren(org.eclipse.emf.ecore.EObject main, org.eclipse.emf.ecore.EObject other, org.eclipse.emf.ecore.EObject ancestor)
      Description copied from interface: IElementsTreeMatcher
      Returns children (without sub-children) of the given elements in a result matched tree.
      Specified by:
      getMatchedChildren in interface IElementsTreeMatcher
      Parameters:
      main - comparing element in main tree
      other - comparing element in other tree
      ancestor - comparing element in ancestor ancestor
      Returns:
      list of children in a matched tree, can be empty, never null
    • matchElements

      protected abstract void matchElements(org.eclipse.emf.ecore.EObject container, ComparedObjectPath containerPath, ComparisonSide side)
      Matches child items of the given container and puts them by calling #putElement(EObject, ComparisonSide) method.
      Parameters:
      container - the container to match
      containerPath - the path for the container, never null
      side - the comparison side, never null
    • createItemId

      protected abstract Object createItemId(org.eclipse.emf.ecore.EObject item)
      Creates unique identifier of the given item.
      Parameters:
      item - the item for which to create identifier, never null
      Returns:
      the identifier created, never null
    • getRootPath

      protected abstract ComparedObjectPath getRootPath(org.eclipse.emf.ecore.EObject rootItem)
      Returns the path for the root item.
      Parameters:
      item - the root item, can be null
      Returns:
      the path built
    • createItemId

      protected final Object createItemId(org.eclipse.emf.ecore.EObject main, org.eclipse.emf.ecore.EObject other, org.eclipse.emf.ecore.EObject ancestor)
      Creates unique identifier for elements matched earlier. At least one of input element must not be null.
      Parameters:
      main - element in main tree
      other - element in other tree
      ancestor - element in ancestor tree
      Returns:
      the identifier created, never null
    • buildPath

      protected final ComparedObjectPath buildPath(ComparedObjectPath parentPath, org.eclipse.emf.ecore.EObject matchedObject, org.eclipse.emf.ecore.EStructuralFeature feature)
      Builds path for the specified single feature.
      Parameters:
      parentPath - parent object's path, not null
      matchedObject - the matched object, can be null
      feature - the feature to build path for, not null
      Returns:
      the built path, never null
    • buildPath

      protected final ComparedObjectPath buildPath(ComparedObjectPath parentPath, org.eclipse.emf.ecore.EObject matchedObject, org.eclipse.emf.ecore.EStructuralFeature feature, int position)
      Builds path for the specified many-feature.
      Parameters:
      parentPath - parent object's path, not null
      matchedObject - the matched object, can be null
      feature - the feature to build path for, not null
      position - the object's position in the many-feature array
      Returns:
      the built path, never null
    • putMatchedElement

      protected void putMatchedElement(org.eclipse.emf.ecore.EObject item, ComparedObjectPath path, ComparisonSide side)
      Stores matched element for the given comparison side.
      Parameters:
      item - the item matched, cannot be null
      path - the item's path, cannot be null
      side - the comparison side, cannot be null