Interface Headers.AcceptLanguage.LanguageRange

Enclosing interface:
Headers.AcceptLanguage

public static interface Headers.AcceptLanguage.LanguageRange

Accept language HTTP header language range as defined by RFC 7231 Section 5.3.5.

Since:
1.0
Author:
Jeremy Kuhn
  • Field Details

  • Method Details

    • getLanguageTag

      String getLanguageTag()

      Returns the language range tag.

      Returns:
      the language range tag
    • getPrimarySubTag

      String getPrimarySubTag()

      Returns the language range primary sub-tag.

      Returns:
      the language range primary sub-tag
    • getSecondarySubTag

      String getSecondarySubTag()

      Returns the language range secondary sub-tag.

      Returns:
      the language range secondary sub-tag
    • getWeight

      float getWeight()

      Returns the language range quality value as defined by RFC 7231 Section 5.3.1.

      Returns:
      the language range quality value
    • matches

      default boolean matches(Headers.AcceptLanguage.LanguageRange languageRange)

      Determines whether the specified language range matches the language range.

      Parameters:
      languageRange - the language range to test
      Returns:
      true if the language range matches the range, false otherwise
    • getScore

      default int getScore()

      Calculates and returns the score or the language range used for sorting.

      The score is calculated by assigning a score to the media range part and add all:

      • the range quality value is multiplied by 1000
      • * is worth 0
      • xx is worth 10
      • xx-xx is worth 20
      Returns:
      the score of the language range
    • findFirstMatch

      Returns the first language range in the specified list that matches the specified language range.

      Parameters:
      languageRange - a language range
      languageRanges - a list of language ranges
      Returns:
      an optional returning the first match or an empty optional if no match was found
    • findFirstMatch

      Returns the first item in the specified collection whose language range matches the specified language range.

      Type Parameters:
      T - the type of the item
      Parameters:
      languageRange - a language range
      items - a collection of items
      languageRangeExtractor - a function that extracts the language range of an item
      Returns:
      an optional returning the first match or an empty optional if no match was found