Class MapAdaptor


  • public final class MapAdaptor
    extends Object
    A simple layer on top of maps, which performs snapshot mediation and optimization of what the underlying implementation is.
    • Method Detail

      • getDefaultInstance

        public static MapAdaptor getDefaultInstance()
        Return the default-configured instance.
        Returns:
        the singleton global instance
      • getInstance

        public static MapAdaptor getInstance​(boolean useSingleton,
                                             int copyMaxItems,
                                             int persistMinItems)
      • initialSnapshot

        public <K,​V> Map<K,​V> initialSnapshot​(int expectedSize)
        Creates an initial snapshot. The backing map is selected according to the expected size.
        Parameters:
        expectedSize - Expected map size
        Returns:
        An empty mutable map.
      • takeSnapshot

        public <K,​V> Map<K,​V> takeSnapshot​(Map<K,​V> input)
        Input is treated is supposed to be left unmodified, result must be mutable.
        Parameters:
        input - input map
        Returns:
        An isolated, read-write snapshot of input map
        Throws:
        NullPointerException - if input is null
      • optimize

        public <K,​V> Map<K,​V> optimize​(Map<K,​V> input)
        Input will be thrown away, result will be retained for read-only access or takeSnapshot(Map) purposes.
        Parameters:
        input - non-optimized (read-write) map
        Returns:
        optimized read-only map
        Throws:
        NullPointerException - if input is null