Record Class WebSearchApiResponse

java.lang.Object
java.lang.Record
net.ygbstudio.jbrave.api.response.WebSearchApiResponse
Record Components:
type - The type of the response.
discussions - Forum and discussion results related to the search query.
faq - Frequently asked questions and their answers.
infobox - Structured information box with key details.
locations - Location-based results and points of interest.
mixed - Mixed collection of different result types.
news - News article results.
query - Information about the search query.
videos - Video search results.
web - Standard web search results.
summarizer - AI-generated summary of search results.
rich - Additional rich callback information.
All Implemented Interfaces:
ApiResponse

public record WebSearchApiResponse(String type, Discussions discussions, FAQ faq, GraphInfobox infobox, Locations locations, MixedResponse mixed, News news, WebQuery query, Videos videos, Search web, Summarizer summarizer, RichCallbackInfo rich) extends Record implements ApiResponse
Represents the top-level response from the Brave Search API. This class contains all the different types of search results that can be returned by the API, organized by result type.

This response record contains methods to deserialise and serialise instances.

Factory methods are available for String, File, Reader, and HttpResponse inputs. You can also write the contents of a response object to the filesystem; ApiResponse.write(File) can be useful for that purpose.

  • Constructor Details

    • WebSearchApiResponse

      public WebSearchApiResponse(String type, Discussions discussions, FAQ faq, GraphInfobox infobox, Locations locations, MixedResponse mixed, News news, WebQuery query, Videos videos, Search web, Summarizer summarizer, RichCallbackInfo rich)
      Creates an instance of a WebSearchApiResponse record class.
      Parameters:
      type - the value for the type record component
      discussions - the value for the discussions record component
      faq - the value for the faq record component
      infobox - the value for the infobox record component
      locations - the value for the locations record component
      mixed - the value for the mixed record component
      news - the value for the news record component
      query - the value for the query record component
      videos - the value for the videos record component
      web - the value for the web record component
      summarizer - the value for the summarizer record component
      rich - the value for the rich record component
  • Method Details

    • from

      public static WebSearchApiResponse from(File dataFile)
      Deserializes a WebSearchApiResponse from a JSON File.
      Parameters:
      dataFile - the file containing the JSON response data
      Returns:
      the deserialized response
    • from

      public static WebSearchApiResponse from(String dataString)
      Deserializes a WebSearchApiResponse from a JSON String.
      Parameters:
      dataString - the string containing the JSON response data
      Returns:
      the deserialized response
    • from

      public static WebSearchApiResponse from(Reader dataReader)
      Deserializes a WebSearchApiResponse from a JSON Reader.
      Parameters:
      dataReader - the reader supplying the JSON response data
      Returns:
      the deserialized response
    • from

      public static WebSearchApiResponse from(@NotNull @NotNull HttpResponse<String> dataResponse)
      Deserializes a WebSearchApiResponse from the body of an HTTP response.
      Parameters:
      dataResponse - the HTTP response whose body contains the JSON response data
      Returns:
      the deserialized response
    • 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.
    • type

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

      public Discussions discussions()
      Returns the value of the discussions record component.
      Returns:
      the value of the discussions record component
    • faq

      public FAQ faq()
      Returns the value of the faq record component.
      Returns:
      the value of the faq record component
    • infobox

      public GraphInfobox infobox()
      Returns the value of the infobox record component.
      Returns:
      the value of the infobox record component
    • locations

      public Locations locations()
      Returns the value of the locations record component.
      Returns:
      the value of the locations record component
    • mixed

      public MixedResponse mixed()
      Returns the value of the mixed record component.
      Returns:
      the value of the mixed record component
    • news

      public News news()
      Returns the value of the news record component.
      Returns:
      the value of the news record component
    • query

      public WebQuery query()
      Returns the value of the query record component.
      Returns:
      the value of the query record component
    • videos

      public Videos videos()
      Returns the value of the videos record component.
      Returns:
      the value of the videos record component
    • web

      public Search web()
      Returns the value of the web record component.
      Returns:
      the value of the web record component
    • summarizer

      public Summarizer summarizer()
      Returns the value of the summarizer record component.
      Returns:
      the value of the summarizer record component
    • rich

      public RichCallbackInfo rich()
      Returns the value of the rich record component.
      Returns:
      the value of the rich record component