Interface RequestCookies


public interface RequestCookies
A request Cookie collection.
Since:
2.1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    List<? extends Cookie>
    getAll(String name)
    Gets all values of the cookie with the given name, or an empty List if none exists.
    Gets the first cookie with the given name, or null if none exists.
    getFirst(String name, ValueTransformation valueTransformation)
    Gets the first cookie with the given name, or null if none exists or the cookie value could not be transformed successfully.
    Gets the cookie with the given name, null if none exists, or throw an error if multiple cookies exist with the given name.
    getSingleOrError(String name, ValueTransformation valueTransformation)
    Gets the cookie with the given name, or null if none exists or the cookie value could not be transformed successfully.
    map()
    Get a Map containing all cookies sent with the Request, where each entry has the cookie name as the key, and a List of the the cookies with that name as the value.
  • Method Details

    • getFirst

      @Nullable @Nullable Cookie getFirst(String name)
      Gets the first cookie with the given name, or null if none exists.
      Parameters:
      name - of the cookie
      Returns:
      the first cookie with the given name, if any.
    • getFirst

      @Nullable @Nullable Cookie getFirst(String name, ValueTransformation valueTransformation)
      Gets the first cookie with the given name, or null if none exists or the cookie value could not be transformed successfully.
      Parameters:
      name - of the cookie
      valueTransformation - the transformation that should be applied to the cookie value
      Returns:
      the first cookie with the given name, if any.
    • getSingleOrError

      @Nullable @Nullable Cookie getSingleOrError(String name) throws MultipleCookiesException
      Gets the cookie with the given name, null if none exists, or throw an error if multiple cookies exist with the given name.
      Parameters:
      name - of the cookie
      Returns:
      the cookie with the given name, if any.
      Throws:
      MultipleCookiesException - in case more than one cookie exists
    • getSingleOrError

      @Nullable @Nullable Cookie getSingleOrError(String name, ValueTransformation valueTransformation) throws MultipleCookiesException
      Gets the cookie with the given name, or null if none exists or the cookie value could not be transformed successfully.
      Parameters:
      name - of the cookie
      valueTransformation - the transformation that should be applied to the cookie value
      Returns:
      the cookie with the given name, if any.
      Throws:
      MultipleCookiesException - in case more than one cookie exists
    • getAll

      List<? extends Cookie> getAll(String name)
      Gets all values of the cookie with the given name, or an empty List if none exists.

      All cookies are returned with the actual value they were sent by the client. This means that encrypted or signed cookies are not decrypted or signature-verified, respectively.

      Parameters:
      name - of the cookie
      Returns:
      the raw values of the cookie with the given name.
    • map

      Map<String,NonEmptyList<? extends Cookie>> map()
      Get a Map containing all cookies sent with the Request, where each entry has the cookie name as the key, and a List of the the cookies with that name as the value. Notice that this method has the same restriction on encrypted and signed cookies as the getAll(String) method.
      Returns:
      a Map containing all cookies sent with the request