public final class ResponseCookie extends HttpCookie
HttpCookie
subclass with the additional attributes allowed in
the "Set-Cookie" response header. To build an instance use the from(java.lang.String, java.lang.String)
static method.Modifier and Type | Class and Description |
---|---|
static interface |
ResponseCookie.ResponseCookieBuilder
A builder for a server-defined HttpCookie with attributes.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
static ResponseCookie.ResponseCookieBuilder |
from(String name,
String value)
Factory method to obtain a builder for a server-defined cookie that starts
with a name-value pair and may also include attributes.
|
String |
getDomain()
Return the cookie "Domain" attribute, or
null if not set. |
Duration |
getMaxAge()
Return the cookie "Max-Age" attribute in seconds.
|
String |
getPath()
Return the cookie "Path" attribute, or
null if not set. |
int |
hashCode() |
boolean |
isHttpOnly()
Return
true if the cookie has the "HttpOnly" attribute. |
boolean |
isSecure()
Return
true if the cookie has the "Secure" attribute. |
String |
toString() |
getName, getValue
public Duration getMaxAge()
A positive value indicates when the cookie expires relative to the current time. A value of 0 means the cookie should expire immediately. A negative value means no "Max-Age" attribute in which case the cookie is removed when the browser is closed.
@Nullable public String getDomain()
null
if not set.public boolean isSecure()
true
if the cookie has the "Secure" attribute.public boolean isHttpOnly()
true
if the cookie has the "HttpOnly" attribute.public boolean equals(Object other)
equals
in class HttpCookie
public int hashCode()
hashCode
in class HttpCookie
public String toString()
toString
in class HttpCookie
public static ResponseCookie.ResponseCookieBuilder from(String name, String value)
name
- the cookie namevalue
- the cookie value