Class CookieMap<P>

java.lang.Object
org.apache.commons.chain.web.ParameterMap<P,javax.servlet.http.Cookie>
org.apache.commons.chain.web.javax.internal.CookieMap<P>
Type Parameters:
P - the type of the parameter-provider
All Implemented Interfaces:
Map<String,javax.servlet.http.Cookie>

public class CookieMap<P> extends ParameterMap<P,javax.servlet.http.Cookie>
Implementation of Map for cookies with a parameter-provider.
Since:
Chain 1.3
Author:
Graff Stefan
  • Constructor Details

    • CookieMap

      public CookieMap(P request, Supplier<javax.servlet.http.Cookie[]> cookiesSupplier)
      The constructor for the Map for cookies.
      Parameters:
      request - the request with the cookies
      cookiesSupplier - Supplier to return the Cookie-Array in this object
  • Method Details

    • containsKey

      public boolean containsKey(Object key)
      Returns true if this cookie-map contains a mapping for the specified cookie-name.
      Specified by:
      containsKey in interface Map<String,javax.servlet.http.Cookie>
      Overrides:
      containsKey in class ParameterMap<P,javax.servlet.http.Cookie>
      Parameters:
      key - The key whose presence in this cookie-map is to be tested
      Returns:
      true if this cookie-map contains a mapping for the specified cookie-name.
    • containsValue

      public boolean containsValue(Object value)
      Returns true if this cookie-map maps one or more keys to the specified cookie.
      Specified by:
      containsValue in interface Map<String,javax.servlet.http.Cookie>
      Overrides:
      containsValue in class ParameterMap<P,javax.servlet.http.Cookie>
      Parameters:
      value - cookie whose presence in this cookie-map is to be tested
      Returns:
      true if this cookie-map maps one or more keys to the specified cookie
    • entrySet

      public Set<Map.Entry<String,javax.servlet.http.Cookie>> entrySet()
      Returns a Set view of the mappings contained in this cookie-map. The set is not backed by the cookie-map, so changes to the cookie-map are not reflected in the set, and vice-versa.
      Specified by:
      entrySet in interface Map<String,javax.servlet.http.Cookie>
      Overrides:
      entrySet in class ParameterMap<P,javax.servlet.http.Cookie>
      Returns:
      a set view of the mappings contained in this cookie-map
    • get

      public javax.servlet.http.Cookie get(Object key)
      Returns the cookie to which the specified cookie-name is mapped, or null if this cookie-map contains no mapping for the cookie-name.
      Specified by:
      get in interface Map<String,javax.servlet.http.Cookie>
      Overrides:
      get in class ParameterMap<P,javax.servlet.http.Cookie>
      Parameters:
      key - the cookie-name whose associated value is to be returned
      Returns:
      the value to which the specified key is mapped, or null if this cookie-map contains no mapping for the cookie-name
      See Also:
    • isEmpty

      public boolean isEmpty()
      Returns true if this cookie-map contains no cookies.
      Specified by:
      isEmpty in interface Map<String,javax.servlet.http.Cookie>
      Overrides:
      isEmpty in class ParameterMap<P,javax.servlet.http.Cookie>
      Returns:
      true if this cookie-map contains no cookies
    • keySet

      public Set<String> keySet()
      Returns a Set view of the cookies contained in this cookie-map. The set is not backed by the cookie-map, so changes to the cookie-map are not reflected in the set, and vice-versa.
      Specified by:
      keySet in interface Map<String,javax.servlet.http.Cookie>
      Overrides:
      keySet in class ParameterMap<P,javax.servlet.http.Cookie>
      Returns:
      a set view of the cookies contained in this cookie-map
    • size

      public int size()
      Returns the number of cookies in this cookie-map.
      Specified by:
      size in interface Map<String,javax.servlet.http.Cookie>
      Overrides:
      size in class ParameterMap<P,javax.servlet.http.Cookie>
      Returns:
      the number of cookies in this cookie-map
    • values

      public Collection<javax.servlet.http.Cookie> values()
      Returns a Collection view of the cookies contained in this cookie-map. The collection is not backed by the cookie-map, so changes to the cookie-map are not reflected in the collection, and vice-versa.
      Specified by:
      values in interface Map<String,javax.servlet.http.Cookie>
      Overrides:
      values in class ParameterMap<P,javax.servlet.http.Cookie>
      Returns:
      a view of the cookies contained in this cookie-map
    • hashCode

      public int hashCode()
      Returns the hash code value for this cookie-map. The hash code of a cookie-map is defined to be the sum of the hash codes of each entry in the cookie-map's entrySet() view. This ensures that m1.equals(m2) implies that m1.hashCode()==m2.hashCode() for any two parameter-maps m1 and m2, as required by the general contract of Object.hashCode().
      Specified by:
      hashCode in interface Map<String,javax.servlet.http.Cookie>
      Overrides:
      hashCode in class ParameterMap<P,javax.servlet.http.Cookie>
      Returns:
      the hash code value for this cookie-map
      Implementation Requirements:
      This implementation calls the hashCode() from the parameter-map.
    • equals

      public boolean equals(Object obj)
      Compares the specified object with this cookie-map for equality. Returns true if the given object is also a cookie-map and the two cookie-maps represent the same mappings. More formally, two cookie-maps m1 and m2 represent the same mappings if m1.entrySet().equals(m2.entrySet()).
      Specified by:
      equals in interface Map<String,javax.servlet.http.Cookie>
      Overrides:
      equals in class ParameterMap<P,javax.servlet.http.Cookie>
      Parameters:
      obj - object to be compared for equality with this cookie-map
      Returns:
      true if the specified object is equal to this cookie-map