Class PotentiallyMultiValuedMap

  • All Implemented Interfaces:
    Recyclable

    public class PotentiallyMultiValuedMap
    extends java.lang.Object
    implements Recyclable
    This map is a mixture of a map with a single value and a map with multiple values.

    When there is only one value associated with a key, this map just the key as-is when calling get(String). But when add(String, String) has been called multiple times for a given key, get(String) will return a collection of values.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.String key, java.lang.String value)
      Adds a value to this map.
      boolean containsIgnoreCase​(java.lang.String key)  
      void copyFrom​(PotentiallyMultiValuedMap other)  
      java.lang.Object get​(java.lang.String key)  
      java.util.List<java.lang.String> getAll​(java.lang.String key)
      Gets all the values which age associated with a given key.
      java.lang.String getFirst​(java.lang.String key)
      Gets the first value which is associated with a given key.
      java.lang.String getKey​(int i)  
      java.lang.Object getValue​(int i)  
      boolean isEmpty()  
      void removeIgnoreCase​(java.lang.String key)  
      void resetState()
      resets pooled object state so it can be reused
      void set​(int index, java.lang.String value)  
      void set​(java.lang.String key, java.lang.String[] values)  
      int size()  
      • Methods inherited from class java.lang.Object

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

      • PotentiallyMultiValuedMap

        public PotentiallyMultiValuedMap()
      • PotentiallyMultiValuedMap

        public PotentiallyMultiValuedMap​(int initialSize)
    • Method Detail

      • add

        public void add​(java.lang.String key,
                        java.lang.String value)
        Adds a value to this map.

        If the given key already exists, the current value and the given value are added to a collection, which is set as the new value.

        Parameters:
        key - The key.
        value - The value.
      • set

        public void set​(java.lang.String key,
                        java.lang.String[] values)
      • getFirst

        @Nullable
        public java.lang.String getFirst​(java.lang.String key)
        Gets the first value which is associated with a given key.
        Parameters:
        key - The key you want to get the associated value for.
        Returns:
        The first value which is associated with a given key.
      • get

        @Nullable
        public java.lang.Object get​(java.lang.String key)
      • getAll

        public java.util.List<java.lang.String> getAll​(java.lang.String key)
        Gets all the values which age associated with a given key.

        If there is only one value associated with the given key, the value is wrapped inside a collection.

        Parameters:
        key - The key you want to get the associated value for.
        Returns:
        All the values which age associated with a given key.
      • isEmpty

        public boolean isEmpty()
      • resetState

        public void resetState()
        Description copied from interface: Recyclable
        resets pooled object state so it can be reused
        Specified by:
        resetState in interface Recyclable
      • getKey

        public java.lang.String getKey​(int i)
      • getValue

        public java.lang.Object getValue​(int i)
      • size

        public int size()
      • removeIgnoreCase

        public void removeIgnoreCase​(java.lang.String key)
      • set

        public void set​(int index,
                        java.lang.String value)
      • containsIgnoreCase

        public boolean containsIgnoreCase​(java.lang.String key)