Class MergeResult<T>

  • Type Parameters:
    T - The type of the result of the merge handler.

    public class MergeResult<T>
    extends java.lang.Object

    This class represents the result of a mapping merge handled by a MappingSetMergerHandler. This class is only relevant to mapping types which have children, which includes both top level and inner class mappings, and method mappings.

    This class holds 2 values:

    1. The merge result
    2. The child mappings on the right to merge into the merge result with the left side of the merge

    When a merge occurs with mappings which contain child data the merger will need to recurse into the child data and merge those mappings too. Depending on the situation this may not be desirable, or you may wish to control specifically which mappings do or don't get merged. Typically there will only be one mapping on the right side, but some situations, such as duplicates and method mappings, may have multiple mappings that you may want merged. By storing those mappings in a list in that class that allows the merger to have the most flexibility in choosing which mappings are or aren't merged.

    Since:
    0.5.4
    API Note:
    This class should only contains the mappings on the right side of the merge which should be mapped. The left side is considered the source and is always mapped.
    • Constructor Summary

      Constructors 
      Constructor Description
      MergeResult​(T result)
      Create a new MergeResult with a result and no mappings to merge.
      MergeResult​(T result, java.util.List<T> mappingsToMap)
      Create a new MergeResult with a result and a list of mappings to merge.
      MergeResult​(T result, T mappingToMerge)
      Create a new MergeResult with a result and only one mapping to merge.
    • Constructor Detail

      • MergeResult

        public MergeResult​(T result)
        Create a new MergeResult with a result and no mappings to merge.
        Parameters:
        result - The result of the merge operation, may be null.
      • MergeResult

        public MergeResult​(T result,
                           T mappingToMerge)
        Create a new MergeResult with a result and only one mapping to merge.
        Parameters:
        result - The result of the merge operation, may be null.
        mappingToMerge - The mapping to merge into the result, must not be null.
      • MergeResult

        public MergeResult​(T result,
                           java.util.List<T> mappingsToMap)
        Create a new MergeResult with a result and a list of mappings to merge.
        Parameters:
        result - The result of the merge operation, may be null.
        mappingsToMap - The mappings to merge into the result, must not be null, and no entries may be null. May be empty.
    • Method Detail

      • getResult

        public T getResult()
        Returns:
        The returned result of the duplicate merge action, may be null.
      • getMappingsToMap

        public java.util.List<T> getMappingsToMap()
        Returns:
        The mappings to map child entries from into the new mapping returned by getResult(). Cannot be null.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object