Module jakarta.ws.rs
Package jakarta.ws.rs.core
Class NewCookie.AbstractNewCookieBuilder<T extends NewCookie.AbstractNewCookieBuilder<T>>
java.lang.Object
jakarta.ws.rs.core.Cookie.AbstractCookieBuilder<NewCookie.AbstractNewCookieBuilder<T>>
jakarta.ws.rs.core.NewCookie.AbstractNewCookieBuilder<T>
- Type Parameters:
T
- the current AbstractNewCookieBuilder type.
- Direct Known Subclasses:
NewCookie.Builder
- Enclosing class:
NewCookie
public abstract static class NewCookie.AbstractNewCookieBuilder<T extends NewCookie.AbstractNewCookieBuilder<T>>
extends Cookie.AbstractCookieBuilder<NewCookie.AbstractNewCookieBuilder<T>>
JAX-RS abstract
NewCookie
builder class.- Since:
- 3.1
-
Constructor Summary
ConstructorDescriptionAbstractNewCookieBuilder
(Cookie cookie) Create a new instance supplementing the information in the supplied cookie.Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionabstract NewCookie
build()
Build a newNewCookie
instance using all the configuration previously specified in this builder.Set the comment associated with the cookie.Set the cookie expiry date.httpOnly
(boolean httpOnly) Whether the cookie will only be visible as part of an HTTP request.maxAge
(int maxAge) Set the maximum age of the the cookie in seconds.sameSite
(NewCookie.SameSite sameSite) Set the attribute that controls whether the cookie is sent with cross-origin requests, providing protection against cross-site request forgery.secure
(boolean secure) Whether the cookie will only be sent over a secure connection.Methods inherited from class jakarta.ws.rs.core.Cookie.AbstractCookieBuilder
domain, path, value, version
-
Constructor Details
-
AbstractNewCookieBuilder
Create a new instance.- Parameters:
name
- the name of the cookie.
-
AbstractNewCookieBuilder
Create a new instance supplementing the information in the supplied cookie.- Parameters:
cookie
- the cookie to clone.
-
-
Method Details
-
comment
-
maxAge
Set the maximum age of the the cookie in seconds. Cookies older than the maximum age are discarded. A cookie can be unset by sending a new cookie with maximum age of 0 since it will overwrite any existing cookie and then be immediately discarded. The default value of-1
indicates that the cookie will be discarded at the end of the browser/application session.- Parameters:
maxAge
- the maximum age in seconds.- Returns:
- the updated builder instance.
- See Also:
-
expiry
Set the cookie expiry date. Cookies whose expiry date has passed are discarded. A cookie can be unset by setting a new cookie with an expiry date in the past, typically the lowest possible date that can be set.Note that it is recommended to use
Max-Age
to control cookie expiration, however some browsers do not understandMax-Age
, in which case settingExpires
parameter may be necessary.- Parameters:
expiry
- the cookie expiry date- Returns:
- the updated builder instance.
- See Also:
-
secure
Whether the cookie will only be sent over a secure connection. Defaults tofalse
.- Parameters:
secure
- specifies whether the cookie will only be sent over a secure connection.- Returns:
- the updated builder instance.
-
httpOnly
Whether the cookie will only be visible as part of an HTTP request. Defaults tofalse
.- Parameters:
httpOnly
- iftrue
make the cookie HTTP only, i.e. only visible as part of an HTTP request.- Returns:
- the updated builder instance.
-
sameSite
Set the attribute that controls whether the cookie is sent with cross-origin requests, providing protection against cross-site request forgery.- Parameters:
sameSite
- specifies the value of theSameSite
cookie attribute.- Returns:
- the updated builder instance.
-
build
Build a newNewCookie
instance using all the configuration previously specified in this builder.- Specified by:
build
in classCookie.AbstractCookieBuilder<NewCookie.AbstractNewCookieBuilder<T extends NewCookie.AbstractNewCookieBuilder<T>>>
- Returns:
- a new
NewCookie
instance. - Throws:
IllegalArgumentException
- if name isnull
.
-