- java.lang.Object
-
- com.github.robtimus.servlet.http.CookieUtils
-
public final class CookieUtils extends Object
A utility class for cookies.- Author:
- Rob Spoor
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stream<Cookie>
cookieStream(HttpServletRequest request)
Returns all cookies in a request as a stream.static Optional<Cookie>
findCookie(HttpServletRequest request, String name)
Tries to find a specific cookie in a request.
-
-
-
Method Detail
-
findCookie
public static Optional<Cookie> findCookie(HttpServletRequest request, String name)
Tries to find a specific cookie in a request.- Parameters:
request
- The request to find the cookie in.name
- The name of the cookie to find. This is case sensitive.- Returns:
- An
Optional
describing the cookie with the given name, orOptional.empty()
if the request does not have such a cookie. - Throws:
NullPointerException
- If the given request isnull
.
-
cookieStream
public static Stream<Cookie> cookieStream(HttpServletRequest request)
Returns all cookies in a request as a stream.- Parameters:
request
- The request to return all cookies of.- Returns:
- A stream with all cookies in the given request; never
null
but possibly empty. - Throws:
NullPointerException
- If the given request isnull
.
-
-