Class AbstractMergeableElementList

All Implemented Interfaces:
Mergeable
Direct Known Subclasses:
ComponentsElement, RequirementsElement

public abstract class AbstractMergeableElementList extends AbstractMergeableElement
Base class that allows for handling merging two element lists.

TODO Refactor and make this extend AbstractMergeableElement which is what this actually is, but with added bits for merging child element lists.

  • Constructor Details

    • AbstractMergeableElementList

      public AbstractMergeableElementList(org.jdom2.Element element)
  • Method Details

    • parseRecurringMergeables

      protected Map parseRecurringMergeables(String tagName, List compositeKeyList, Mergeable parentElement) throws 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:
      Exception - if there was an error parsing and registering Mergeable instances
    • lookupTagInstanceByName

      private DescriptorTag lookupTagInstanceByName(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

      public void merge(Mergeable me) throws MergeException
      Description copied from class: AbstractMergeableSupport
      Merges an element of same type.
      Specified by:
      merge in interface Mergeable
      Overrides:
      merge in class AbstractMergeableElement
      Parameters:
      me - Another entity that is mergeable.
      Throws:
      MergeException - if there was an error merging the mergeables.
    • merge

      protected void merge(org.jdom2.Element parent, Map dMap, Map rMap) throws 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:
      Exception - if there was an error merging both the maps.
    • isMergeRequired

      private boolean isMergeRequired(Set dKeySet, 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 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 List getElementNamesForConflictResolution(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.