Interface ExtensionsMerger

All Known Implementing Classes:
DefaultExtensionsMerger

@PublicSpi public interface ExtensionsMerger
This interface is a callback asking code to merge two maps with an eye to creating the graphql `extensions` value.

How best to merge two maps is hard to know up front. Should it be a shallow clone or a deep one, should keys be replaced or not and should lists of value be combined? The ExtensionsMerger is the interface asked to do this.

This interface will be called repeatedly for each change that has been added to the ExtensionsBuilder and it is expected to merge the two maps as it sees fit

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final ExtensionsMerger
    A default implementation will do the following It will deep merge the maps It concatenate lists when they occur under the same key It will add any keys from the right hand side map that are not present in the left If a key is in both the left and right side, it will prefer the right hand side It will try to maintain key order if the maps are ordered
  • Method Summary

    Modifier and Type
    Method
    Description
    @NonNull Map<Object,Object>
    merge(@NonNull Map<Object,Object> leftMap, @NonNull Map<Object,Object> rightMap)
    Called to merge the map on the left with the map on the right according to whatever code strategy some-one might envisage
  • Field Details

    • DEFAULT

      static final ExtensionsMerger DEFAULT
      A default implementation will do the following
      • It will deep merge the maps
      • It concatenate lists when they occur under the same key
      • It will add any keys from the right hand side map that are not present in the left
      • If a key is in both the left and right side, it will prefer the right hand side
      • It will try to maintain key order if the maps are ordered
  • Method Details

    • merge

      @NonNull Map<Object,Object> merge(@NonNull Map<Object,Object> leftMap, @NonNull Map<Object,Object> rightMap)
      Called to merge the map on the left with the map on the right according to whatever code strategy some-one might envisage

      The map on the left is guaranteed to have been encountered before the map on the right

      Parameters:
      leftMap - the map on the left
      rightMap - the map on the right
      Returns:
      a non null merged map