Record Class Cookie

java.lang.Object
java.lang.Record
dev.voidframework.web.http.Cookie
Record Components:
name - The cookie name
value - The cookie value
domain - The cookie domain
path - The cookie path
isHttpOnly - Is the cookie only be accessed via HTTP?
isSecure - Is the cookie secured? If true, sent only for HTTPS requests
sameSiteMode - The same site mode (None, Lax, or Strict)
timeToLive - The cookie time to live

public record Cookie(String name, String value, String domain, String path, boolean isHttpOnly, boolean isSecure, String sameSiteMode, Duration timeToLive) extends Record
A Cookie.
  • Constructor Details

    • Cookie

      public Cookie(String name, String value, String domain, String path, boolean isHttpOnly, boolean isSecure, String sameSiteMode, Duration timeToLive)
      Creates an instance of a Cookie record class.
      Parameters:
      name - the value for the name record component
      value - the value for the value record component
      domain - the value for the domain record component
      path - the value for the path record component
      isHttpOnly - the value for the isHttpOnly record component
      isSecure - the value for the isSecure record component
      sameSiteMode - the value for the sameSiteMode record component
      timeToLive - the value for the timeToLive record component
  • Method Details

    • of

      public static Cookie of(String name, String value)
      Build a new Cookie.
      Parameters:
      name - The cookie name
      value - The cookie value
      Returns:
      Newly created cookie
    • of

      public static Cookie of(String name, String value, boolean isHttpOnly, boolean isSecure, Duration timeToLive)
      Build a new Cookie.
      Parameters:
      name - The cookie name
      value - The cookie value
      isHttpOnly - Is the cookie only be accessed via HTTP? isSecure
      isSecure - Is the cookie secured? If true, sent only for HTTPS
      timeToLive - The cookie time to live
      Returns:
      Newly created cookie
    • of

      public static Cookie of(String name, String value, boolean isHttpOnly, boolean isSecure, String sameSiteMode, Duration timeToLive)
      Build a new Cookie.
      Parameters:
      name - The cookie name
      value - The cookie value
      isHttpOnly - Is the cookie only be accessed via HTTP? isSecure
      isSecure - Is the cookie secured? If true, sent only for HTTPS
      sameSiteMode - The same site mode (None, Lax, or Strict)
      timeToLive - The cookie time to live
      Returns:
      Newly created cookie
    • of

      public static Cookie of(String name, String value, Duration timeToLive)
      Build a new Cookie.
      Parameters:
      name - The cookie name
      value - The cookie value
      timeToLive - The cookie time to live
      Returns:
      Newly created cookie
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • value

      public String value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component
    • domain

      public String domain()
      Returns the value of the domain record component.
      Returns:
      the value of the domain record component
    • path

      public String path()
      Returns the value of the path record component.
      Returns:
      the value of the path record component
    • isHttpOnly

      public boolean isHttpOnly()
      Returns the value of the isHttpOnly record component.
      Returns:
      the value of the isHttpOnly record component
    • isSecure

      public boolean isSecure()
      Returns the value of the isSecure record component.
      Returns:
      the value of the isSecure record component
    • sameSiteMode

      public String sameSiteMode()
      Returns the value of the sameSiteMode record component.
      Returns:
      the value of the sameSiteMode record component
    • timeToLive

      public Duration timeToLive()
      Returns the value of the timeToLive record component.
      Returns:
      the value of the timeToLive record component