Record Class Scheme

java.lang.Object
java.lang.Record
org.htmlunit.csp.value.Scheme
Record Components:
value - the scheme name in lowercase, without the trailing colon (e.g. "https", "data")

public record Scheme(String value) extends Record
Represents a CSP scheme-source value, e.g. https: or data:.

A scheme-source is a URI scheme followed by a colon. Per RFC 3986 ยง3.1, schemes are case-insensitive, so the value is stored in its canonical lowercase form.

Author:
Salvation Team
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Scheme(String value)
    Creates an instance of a Scheme record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Parses a scheme-source from its CSP string representation.
    Returns the CSP string representation of this scheme-source (the lowercase scheme name followed by a colon, e.g.
    Returns the value of the value record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Scheme

      public Scheme(String value)
      Creates an instance of a Scheme record class.
      Parameters:
      value - the value for the value record component
  • Method Details

    • parseScheme

      public static Optional<Scheme> parseScheme(String value)
      Parses a scheme-source from its CSP string representation.

      The input must match the scheme grammar followed by a colon (e.g. "https:"). The scheme is lowercased per RFC 3986.

      Parameters:
      value - the CSP scheme-source token (e.g. "https:" or "data:")
      Returns:
      an Optional containing the parsed Scheme, or empty if the value does not match the scheme-source grammar
    • toString

      public String toString()
      Returns the CSP string representation of this scheme-source (the lowercase scheme name followed by a colon, e.g. "https:").
      Specified by:
      toString in class Record
      Returns:
      the scheme-source string
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • value

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