Enum Class BraveHeaders

java.lang.Object
java.lang.Enum<BraveHeaders>
net.ygbstudio.jbrave.core.model.BraveHeaders
All Implemented Interfaces:
Serializable, Comparable<BraveHeaders>, Constable, SearchHeader

public enum BraveHeaders extends Enum<BraveHeaders> implements SearchHeader
Enumeration of possible Brave Search API headers.

Used as a shorthand for setting custom headers in the API requests.

  • Enum Constant Details

    • SUBSCRIPTION_TOKEN

      public static final BraveHeaders SUBSCRIPTION_TOKEN
      Subscription token identifying the calling client.
    • LATITUDE

      public static final BraveHeaders LATITUDE
      Client latitude in degrees, in the range [-90.0, +90.0].
    • LONGITUDE

      public static final BraveHeaders LONGITUDE
      Client longitude in degrees, in the range [-180.0, +180.0].
    • TIMEZONE

      public static final BraveHeaders TIMEZONE
      IANA timezone of the client's device (for example "America/Costa_Rica").
    • CITY

      public static final BraveHeaders CITY
      Generic name of the client's city.
    • STATE

      public static final BraveHeaders STATE
      First-level administrative subdivision (ISO 3166-2); up to three characters.
    • STATE_NAME

      public static final BraveHeaders STATE_NAME
      Human-readable name of the first-level administrative subdivision.
    • COUNTRY

      public static final BraveHeaders COUNTRY
      Two-letter country code (ISO 3166-1 alpha-2).
    • POSTAL_CODE

      public static final BraveHeaders POSTAL_CODE
      Client's postal code.
    • USER_AGENT

      public static final BraveHeaders USER_AGENT
      User-Agent request header.
    • CACHE_CONTROL

      public static final BraveHeaders CACHE_CONTROL
      Cache-Control request header; send no-cache to prevent caching.
    • API_VERSION

      public static final BraveHeaders API_VERSION
      Api-Version request header; check the API changelog for the current value.
    • X_RATE_LIMIT

      public static final BraveHeaders X_RATE_LIMIT
      X-RateLimit-Limit response header reporting the plan's request limit.
    • X_RATE_LIMIT_POLICY

      public static final BraveHeaders X_RATE_LIMIT_POLICY
      X-RateLimit-Policy response header describing the rate-limit policy.
    • X_RATE_LIMIT_REMAINING

      public static final BraveHeaders X_RATE_LIMIT_REMAINING
      X-RateLimit-Remaining response header reporting the remaining request quota.
    • X_RATE_LIMIT_RESET

      public static final BraveHeaders X_RATE_LIMIT_RESET
      X-RateLimit-Reset response header reporting the time until the quota resets.
  • Method Details

    • values

      public static BraveHeaders[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static BraveHeaders valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • extract

      public List<String> extract(@NotNull @NotNull HttpHeaders headers)
      Extracts a list of header values of the specified header from the HTTP headers.
      Parameters:
      headers - the HTTP headers to extract values from
      Returns:
      a list of header values of the specified header
    • extract

      public <R> Optional<R> extract(@NotNull @NotNull HttpHeaders headers, Function<String,R> transformer)
      Extracts the first value of the specified header from the HTTP headers and transforms it using the provided function.
      Type Parameters:
      R - optional type of the return value
      Parameters:
      headers - the HTTP headers to extract values from
      transformer - the function used to transform the available header
      Returns:
      the transformed first value of the specified header if present, otherwise an empty optional
    • value

      public String value()
      Description copied from interface: SearchHeader
      Returns the value of the header.
      Specified by:
      value in interface SearchHeader
      Returns:
      the value of the header