Class AbstractElementsTreeMatcher
- java.lang.Object
-
- com._1c.g5.v8.dt.compare.matching.AbstractElementsTreeMatcher
-
- All Implemented Interfaces:
IElementsTreeMatcher
- Direct Known Subclasses:
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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected ComparedObjectPath
buildPath(ComparedObjectPath parentPath, org.eclipse.emf.ecore.EObject matchedObject, org.eclipse.emf.ecore.EStructuralFeature feature)
Builds path for the specified single feature.protected 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 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.List<MatchedEmfObjects>
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.MatchedEmfObjects
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.
-
-
-
Constructor Detail
-
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 benull
.- Parameters:
session
- the comparison session, cannot benull
mergeRule
- the merge rule to apply when merging elements tree, cannot benull
main
- main element to compareother
- other element to compareancestor
- ancestor element to compare
-
-
Method Detail
-
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 interfaceIElementsTreeMatcher
- 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 interfaceIElementsTreeMatcher
- Parameters:
main
- comparing element in main treeother
- comparing element in other treeancestor
- 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 matchcontainerPath
- the path for the container, nevernull
side
- the comparison side, nevernull
-
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, nevernull
- 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 benull
- 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 benull
.- Parameters:
main
- element in main treeother
- element in other treeancestor
- 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, notnull
matchedObject
- the matched object, can benull
feature
- the feature to build path for, notnull
- 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, notnull
matchedObject
- the matched object, can benull
feature
- the feature to build path for, notnull
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 benull
path
- the item's path, cannot benull
side
- the comparison side, cannot benull
-
-