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 windowxRateLimitPolicy- an optional of the complete policy specification including time window sizesxRateRemaining- an optional of the number of remaining requests in the current time windowxRateLimitReset- 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 Summary
ConstructorsConstructorDescriptionRateLimitResponse(Optional<XRateLimit> xRateLimit, Optional<XRateLimitPolicy> xRateLimitPolicy, Optional<XRateLimitRemaining> xRateRemaining, Optional<XRateLimitReset> xRateLimitReset) Creates an instance of aRateLimitResponserecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static <T> @NotNull RateLimitResponsefrom(@NotNull HttpResponse<T> httpResponse) Creates a RateLimitResponse object from the headers of anHttpResponse.final inthashCode()Returns a hash code value for this object.toJson()final StringtoString()Returns a string representation of this record class.Returns the value of thexRateLimitrecord component.Returns the value of thexRateLimitPolicyrecord component.Returns the value of thexRateLimitResetrecord component.Returns the value of thexRateRemainingrecord component.
-
Constructor Details
-
RateLimitResponse
public RateLimitResponse(Optional<XRateLimit> xRateLimit, Optional<XRateLimitPolicy> xRateLimitPolicy, Optional<XRateLimitRemaining> xRateRemaining, Optional<XRateLimitReset> xRateLimitReset) Creates an instance of aRateLimitResponserecord class.- Parameters:
xRateLimit- the value for thexRateLimitrecord componentxRateLimitPolicy- the value for thexRateLimitPolicyrecord componentxRateRemaining- the value for thexRateRemainingrecord componentxRateLimitReset- the value for thexRateLimitResetrecord component
-
-
Method Details
-
from
@NotNull public static <T> @NotNull RateLimitResponse from(@NotNull @NotNull HttpResponse<T> httpResponse) Creates a RateLimitResponse object from the headers of anHttpResponse.- 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
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
xRateLimit
Returns the value of thexRateLimitrecord component.- Returns:
- the value of the
xRateLimitrecord component
-
xRateLimitPolicy
Returns the value of thexRateLimitPolicyrecord component.- Returns:
- the value of the
xRateLimitPolicyrecord component
-
xRateRemaining
Returns the value of thexRateRemainingrecord component.- Returns:
- the value of the
xRateRemainingrecord component
-
xRateLimitReset
Returns the value of thexRateLimitResetrecord component.- Returns:
- the value of the
xRateLimitResetrecord component
-