Record Class RateLimitResponse

java.lang.Object
java.lang.Record
net.ygbstudio.jbrave.api.response.RateLimitResponse
Record Components:
xRateLimit - an optional of the rate limit for the current time window
xRateLimitPolicy - an optional of the complete policy specification including time window sizes
xRateRemaining - an optional of the number of remaining requests in the current time window
xRateLimitReset - an optional of the time until the current quota window resets

public record RateLimitResponse(Optional<XRateLimit> xRateLimit, Optional<XRateLimitPolicy> xRateLimitPolicy, Optional<XRateLimitRemaining> xRateRemaining, Optional<XRateLimitReset> xRateLimitReset) extends Record
Constructs a RateLimitResponse with the given rate limit information.

This is a carrier object that extracts and encapsulates all headers related to rate limits in the Brave Search API. If you only need one of these, each header can be extracted individually by using its corresponding factory method from().

See Also:
  • Constructor Details

  • Method Details

    • from

      @NotNull public static <T> @NotNull RateLimitResponse from(@NotNull @NotNull HttpResponse<T> httpResponse)
      Creates a RateLimitResponse object from the headers of an HttpResponse.
      Type Parameters:
      T - the type of the response body
      Parameters:
      httpResponse - the HttpResponse object to extract rate limit information from
      Returns:
      a RateLimitResponse object with the rate limit information extracted from the headers
    • toJson

      public String toJson()
    • 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.
    • xRateLimit

      public Optional<XRateLimit> xRateLimit()
      Returns the value of the xRateLimit record component.
      Returns:
      the value of the xRateLimit record component
    • xRateLimitPolicy

      public Optional<XRateLimitPolicy> xRateLimitPolicy()
      Returns the value of the xRateLimitPolicy record component.
      Returns:
      the value of the xRateLimitPolicy record component
    • xRateRemaining

      public Optional<XRateLimitRemaining> xRateRemaining()
      Returns the value of the xRateRemaining record component.
      Returns:
      the value of the xRateRemaining record component
    • xRateLimitReset

      public Optional<XRateLimitReset> xRateLimitReset()
      Returns the value of the xRateLimitReset record component.
      Returns:
      the value of the xRateLimitReset record component