Class MapUtils


  • public class MapUtils
    extends java.lang.Object
    Provides a standard library of helper functions for Map types.
    • Constructor Summary

      Constructors 
      Constructor Description
      MapUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Map<java.lang.String,​java.lang.Object> merge​(java.util.Map<java.lang.String,​java.lang.Object> original, java.util.Map<java.lang.String,​java.lang.Object> override)
      Returns a new map that is the result of deeply merging original and overrides.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MapUtils

        public MapUtils()
    • Method Detail

      • merge

        @Nonnull
        public static java.util.Map<java.lang.String,​java.lang.Object> merge​(@Nonnull
                                                                                   java.util.Map<java.lang.String,​java.lang.Object> original,
                                                                                   @Nonnull
                                                                                   java.util.Map<java.lang.String,​java.lang.Object> override)
        Returns a new map that is the result of deeply merging original and overrides.

        Each key in original is merged with the corresponding key in overrides as follows: - an explicitly null entry in overrides removes a key in original - a map in original is merged with a map from overrides (via call to merge) - a non map in overrides results in an IllegalStateException - a collection in original is replaced with a collection in overrides - a non collection in overrides results in an IllegalStateException - the value is taken from overrides

        Each remaining key in overrides is then added to the resulting map.

        Parameters:
        original - the original Map
        override - the Map to override/merge into original
        Returns:
        a new Map containing the merge of original and overrides (never null)
        Throws:
        java.lang.IllegalStateException - if incompatible types exist between original and overrides