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
    • LATITUDE

      public static final BraveHeaders LATITUDE
    • LONGITUDE

      public static final BraveHeaders LONGITUDE
    • TIMEZONE

      public static final BraveHeaders TIMEZONE
    • CITY

      public static final BraveHeaders CITY
    • STATE

      public static final BraveHeaders STATE
    • STATE_NAME

      public static final BraveHeaders STATE_NAME
    • COUNTRY

      public static final BraveHeaders COUNTRY
    • POSTAL_CODE

      public static final BraveHeaders POSTAL_CODE
    • USER_AGENT

      public static final BraveHeaders USER_AGENT
    • CACHE_CONTROL

      public static final BraveHeaders CACHE_CONTROL
    • API_VERSION

      public static final BraveHeaders API_VERSION
    • X_RATE_LIMIT

      public static final BraveHeaders X_RATE_LIMIT
    • X_RATE_LIMIT_POLICY

      public static final BraveHeaders X_RATE_LIMIT_POLICY
    • X_RATE_LIMIT_REMAINING

      public static final BraveHeaders X_RATE_LIMIT_REMAINING
    • X_RATE_LIMIT_RESET

      public static final BraveHeaders X_RATE_LIMIT_RESET
  • 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