Class AbstractMergeableElementList

    • Constructor Detail

      • AbstractMergeableElementList

        public AbstractMergeableElementList​(org.jdom2.Element element)
    • Method Detail

      • parseRecurringMergeables

        protected java.util.Map parseRecurringMergeables​(java.lang.String tagName,
                                                         java.util.List compositeKeyList,
                                                         Mergeable parentElement)
                                                  throws java.lang.Exception
        Parses <component> elements and builds a map keyed basd on the list of composite keys specified.
        Parameters:
        tagName - Name of the tag that appears multiple times
        compositeKeyList - List of element/tag names to be used as composite keys to register recurring Mergeable instances.
        parentElement - Mergeable.
        Returns:
        Map of Mergeable instances keyed on the composite key obtained from getElementNamesForConflictResolution(java.util.List)
        Throws:
        java.lang.Exception - if there was an error parsing and registering Mergeable instances
      • lookupTagInstanceByName

        private DescriptorTag lookupTagInstanceByName​(java.lang.String name,
                                                      DescriptorTag[] values)
        Looks up and returns an DescriptorTag instance for the specified tag name.
        Parameters:
        name - key to look up the DescriptorTag instance on.
        Returns:
        DescriptorTag instance whose name matches the name specified. Returns null if no match is found.
      • merge

        protected void merge​(org.jdom2.Element parent,
                             java.util.Map dMap,
                             java.util.Map rMap)
                      throws java.lang.Exception
        Identifies the conflicting elements in the dominant and recessive Map instance and merges as required.
        Parameters:
        parent - Element that is parent for the children in the dominant Map instance. Merged content is added to this element.
        dMap - Dominant Map keyed by the composite key obtained from getElementNamesForConflictResolution(List)
        rMap - Recessive Map keyed by the composite key obtained from getElementNamesForConflictResolution(List)
        Throws:
        java.lang.Exception - if there was an error merging both the maps.
      • isMergeRequired

        private boolean isMergeRequired​(java.util.Set dKeySet,
                                        java.util.Set rKeySet)
        Determines if a merge operation is required for the two sets (dominant and recessive) specified.
        Parameters:
        dKeySet - the dominant set of elements.
        rKeySet - the recessive set of elements.
        Returns:
        true if a merge operation was required.
      • getTagNameForRecurringMergeable

        protected abstract java.lang.String getTagNameForRecurringMergeable()
        Allows the sub classes to provided a tag name that they expect to recurr within them. For instance:
        • <components> expects <component> to recurr within itself.
        • <requirements> expects <requirement> to recurr within itself.
        Returns:
        tag name of the Mergeable element that occurs multiple times.
      • getElementNamesForConflictResolution

        protected abstract java.util.List getElementNamesForConflictResolution​(java.util.List defaultList)
        Description copied from class: AbstractMergeableSupport
        Sub classes should override if they wish to provide a different combination of composite keys for determining conflicts.
        Overrides:
        getElementNamesForConflictResolution in class AbstractMergeableSupport
        Parameters:
        defaultList - the default list.
        Returns:
        the default list.