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(java.lang.Object other) |
static ResponseCookie.ResponseCookieBuilder |
from(java.lang.String name,
java.lang.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.
|
java.lang.String |
getDomain()
Return the cookie "Domain" attribute, or
null if not set. |
java.time.Duration |
getMaxAge()
Return the cookie "Max-Age" attribute in seconds.
|
java.lang.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. |
java.lang.String |
toString() |
getName, getValue
public java.time.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 java.lang.String getDomain()
null
if not set.@Nullable public java.lang.String getPath()
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(java.lang.Object other)
equals
in class HttpCookie
public int hashCode()
hashCode
in class HttpCookie
public java.lang.String toString()
toString
in class HttpCookie
public static ResponseCookie.ResponseCookieBuilder from(java.lang.String name, java.lang.String value)
name
- the cookie namevalue
- the cookie value