Record Class BraveSearchHeader

java.lang.Object
java.lang.Record
net.ygbstudio.jbrave.core.model.BraveSearchHeader
Record Components:
header - the header name
value - the header value

public record BraveSearchHeader(String header, String value) extends Record
A record class representing a Brave Search API header.

This class is an immutable representation of a Brave Search API header, which consists of a header name and a corresponding value. It is used for internal handling of headers.

  • Constructor Details

    • BraveSearchHeader

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

    • fromHeaderMap

      public static <K extends SearchHeader> Stream<BraveSearchHeader> fromHeaderMap(@NotNull @NotNull Map<K,String> headerMap)
      Returns a stream of BraveSearchHeader objects created from the entries of the given map.

      This method takes a map of SearchHeader objects and their corresponding values, and converts them into a stream of BraveSearchHeader objects.

      Type Parameters:
      K - the type of the keys in the map, which must extend SearchHeader
      Parameters:
      headerMap - a map of SearchHeader objects and their corresponding values
      Returns:
      a stream of BraveSearchHeader objects
    • toEntry

      @Contract(" -> new") public @NotNull @Unmodifiable Map.Entry<String,String> toEntry()
      Returns an immutable entry of this header.

      This method is used to convert a BraveSearchHeader object into a Map.Entry object, which is useful for adding headers to the request.

      Returns:
      an immutable entry of this header
    • 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. 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.
    • header

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

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