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 abstractNewCookie
builder class.- Since:
- 3.1
-
-
Constructor Summary
Constructors Constructor Description AbstractNewCookieBuilder(Cookie cookie)
Create a new instance supplementing the information in the supplied cookie.AbstractNewCookieBuilder(String name)
Create a new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract NewCookie
build()
Build a newNewCookie
instance using all the configuration previously specified in this builder.T
comment(String comment)
Set the comment associated with the cookie.T
expiry(Date expiry)
Set the cookie expiry date.T
httpOnly(boolean httpOnly)
Whether the cookie will only be visible as part of an HTTP request.T
maxAge(int maxAge)
Set the maximum age of the the cookie in seconds.T
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.T
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 Detail
-
AbstractNewCookieBuilder
public AbstractNewCookieBuilder(String name)
Create a new instance.- Parameters:
name
- the name of the cookie.
-
AbstractNewCookieBuilder
public AbstractNewCookieBuilder(Cookie cookie)
Create a new instance supplementing the information in the supplied cookie.- Parameters:
cookie
- the cookie to clone.
-
-
Method Detail
-
comment
public T comment(String comment)
Set the comment associated with the cookie.- Parameters:
comment
- the comment.- Returns:
- the updated builder instance.
-
maxAge
public T maxAge(int 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(Date)
-
expiry
public T expiry(Date 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:
maxAge(int)
-
secure
public T secure(boolean 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
public T httpOnly(boolean 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
public T 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.- Parameters:
sameSite
- specifies the value of theSameSite
cookie attribute.- Returns:
- the updated builder instance.
-
build
public abstract NewCookie 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
.
-
-