Class SimpleCookie

java.lang.Object
io.micronaut.http.simple.cookies.SimpleCookie
All Implemented Interfaces:
Cookie, Serializable, Comparable<Cookie>

public class SimpleCookie extends Object implements Cookie
Simple Cookie implementation.
Since:
1.0
Author:
Vladimir Orany
See Also:
  • Constructor Details

    • SimpleCookie

      public SimpleCookie(String name, String value)
      Constructor.
      Parameters:
      name - The name
      value - The value
  • Method Details

    • getName

      @NonNull public @NonNull String getName()
      Specified by:
      getName in interface Cookie
      Returns:
      The name of the cookie
    • getValue

      @NonNull public @NonNull String getValue()
      Specified by:
      getValue in interface Cookie
      Returns:
      The value of the cookie
    • getDomain

      public String getDomain()
      Description copied from interface: Cookie
      Gets the domain name of this Cookie.

      Domain names are formatted according to RFC 2109.

      Specified by:
      getDomain in interface Cookie
      Returns:
      the domain name of this Cookie
    • getPath

      public String getPath()
      Description copied from interface: Cookie
      The path of the cookie. The cookie is visible to all paths below the request path on the server.
      Specified by:
      getPath in interface Cookie
      Returns:
      The cookie path
    • isHttpOnly

      public boolean isHttpOnly()
      Description copied from interface: Cookie
      Checks to see if this Cookie can only be accessed via HTTP. If this returns true, the Cookie cannot be accessed through client side script - But only if the browser supports it.

      See here for reference

      Specified by:
      isHttpOnly in interface Cookie
      Returns:
      True if this Cookie is HTTP-only or false if it isn't
    • isSecure

      public boolean isSecure()
      Specified by:
      isSecure in interface Cookie
      Returns:
      True if the cookie is secure
    • getMaxAge

      public long getMaxAge()
      Specified by:
      getMaxAge in interface Cookie
      Returns:
      The maximum age of the cookie in seconds
    • getSameSite

      public Optional<SameSite> getSameSite()
      Description copied from interface: Cookie
      Checks to see if this Cookie can be sent along cross-site requests. For more information, please look here
      Specified by:
      getSameSite in interface Cookie
      Returns:
      The SameSite attribute of the cookie
    • sameSite

      @NonNull public @NonNull Cookie sameSite(SameSite sameSite)
      Description copied from interface: Cookie
      Determines if this this Cookie can be sent along cross-site requests. For more information, please look here
      Specified by:
      sameSite in interface Cookie
      Parameters:
      sameSite - SameSite value
      Returns:
      This cookie
    • maxAge

      @NonNull public @NonNull Cookie maxAge(long maxAge)
      Description copied from interface: Cookie
      Sets the max age of the cookie in seconds.
      Specified by:
      maxAge in interface Cookie
      Parameters:
      maxAge - The max age
      Returns:
      This cookie
    • value

      Description copied from interface: Cookie
      Sets the value.
      Specified by:
      value in interface Cookie
      Parameters:
      value - The value of the cookie
      Returns:
      This cookie
    • domain

      @NonNull public @NonNull Cookie domain(String domain)
      Description copied from interface: Cookie
      Sets the domain of the cookie.
      Specified by:
      domain in interface Cookie
      Parameters:
      domain - The domain of the cookie
      Returns:
      This cookie
    • path

      @NonNull public @NonNull Cookie path(String path)
      Description copied from interface: Cookie
      Sets the path of the cookie.
      Specified by:
      path in interface Cookie
      Parameters:
      path - The path of the cookie
      Returns:
      This cookie
    • secure

      @NonNull public @NonNull Cookie secure(boolean secure)
      Description copied from interface: Cookie
      Sets whether the cookie is secure.
      Specified by:
      secure in interface Cookie
      Parameters:
      secure - Is the cookie secure
      Returns:
      This cookie
    • httpOnly

      @NonNull public @NonNull Cookie httpOnly(boolean httpOnly)
      Description copied from interface: Cookie
      Sets whether the cookie is HTTP-Only.
      Specified by:
      httpOnly in interface Cookie
      Parameters:
      httpOnly - Is the cookie HTTP-Only
      Returns:
      This cookie
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(Cookie c)
      Specified by:
      compareTo in interface Comparable<Cookie>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object