public final class ResponseCookie extends HttpCookie
HttpCookie
sub-class 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 | Field and Description |
---|---|
private java.util.Optional<java.lang.String> |
domain |
private boolean |
httpOnly |
private java.time.Duration |
maxAge |
private java.util.Optional<java.lang.String> |
path |
private boolean |
secure |
Modifier | Constructor and Description |
---|---|
private |
ResponseCookie(java.lang.String name,
java.lang.String value,
java.time.Duration maxAge,
java.lang.String domain,
java.lang.String path,
boolean secure,
boolean httpOnly)
Private constructor.
|
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.util.Optional<java.lang.String> |
getDomain()
Return the cookie "Domain" attribute.
|
java.time.Duration |
getMaxAge()
Return the cookie "Max-Age" attribute in seconds.
|
java.util.Optional<java.lang.String> |
getPath()
Return the cookie "Path" attribute.
|
int |
hashCode() |
boolean |
isHttpOnly()
Return
true if the cookie has the "HttpOnly" attribute. |
boolean |
isSecure()
Return
true if the cookie has the "Secure" attribute. |
getName, getValue
private final java.time.Duration maxAge
private final java.util.Optional<java.lang.String> domain
private final java.util.Optional<java.lang.String> path
private final boolean secure
private final boolean httpOnly
private ResponseCookie(java.lang.String name, java.lang.String value, java.time.Duration maxAge, java.lang.String domain, java.lang.String path, boolean secure, boolean httpOnly)
from(String, String)
.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.
public java.util.Optional<java.lang.String> getDomain()
public java.util.Optional<java.lang.String> getPath()
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 static ResponseCookie.ResponseCookieBuilder from(java.lang.String name, java.lang.String value)
name
- the cookie namevalue
- the cookie value