Module io.inverno.mod.http.base
Package io.inverno.mod.http.base.header
Interface Headers.AcceptLanguage
- All Superinterfaces:
Header
- Enclosing class:
Headers
Accept-language HTTP header as defined by RFC 7231 Section 5.3.5.
https://tools.ietf.org/html/rfc4647#section-3.3.1- Since:
- 1.0
- Author:
- Jeremy Kuhn
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Accept language HTTP header language range as defined by RFC 7231 Section 5.3.5. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault Collection
<Headers.AcceptMatch<Headers.AcceptLanguage.LanguageRange, Headers.AcceptLanguage.LanguageRange>> findAllMatch
(Collection<Headers.AcceptLanguage.LanguageRange> languageRanges) Returns all the language ranges in the specified collection that matches the accept language header sorted from best to worst.default <T> Collection
<Headers.AcceptMatch<Headers.AcceptLanguage.LanguageRange, T>> findAllMatch
(Collection<T> items, Function<T, Headers.AcceptLanguage.LanguageRange> languageRangeExtractor) Returns all the items in the specified collection whose language range matches the accept language header sorted from best to worst.default Optional
<Headers.AcceptMatch<Headers.AcceptLanguage.LanguageRange, Headers.AcceptLanguage.LanguageRange>> findBestMatch
(Collection<Headers.AcceptLanguage.LanguageRange> languageRanges) Returns the language range in the specified collection that best matches the accept language header.default <T> Optional
<Headers.AcceptMatch<Headers.AcceptLanguage.LanguageRange, T>> findBestMatch
(Collection<T> items, Function<T, Headers.AcceptLanguage.LanguageRange> languageRangeExtractor) Returns the item from the specified collection whose language range best matches the accept language header.Returns the list of language ranges defined in the accept language header.static Optional
<Headers.AcceptLanguage> merge
(List<Headers.AcceptLanguage> acceptLanguageHeaders) Merges multiple accept language headers into one.Methods inherited from interface io.inverno.mod.http.base.header.Header
getHeaderName, getHeaderValue
-
Field Details
-
ALL
Accept all header: *
-
-
Method Details
-
getLanguageRanges
List<Headers.AcceptLanguage.LanguageRange> getLanguageRanges()Returns the list of language ranges defined in the accept language header.
- Returns:
- a list of language ranges
-
findBestMatch
default Optional<Headers.AcceptMatch<Headers.AcceptLanguage.LanguageRange,Headers.AcceptLanguage.LanguageRange>> findBestMatch(Collection<Headers.AcceptLanguage.LanguageRange> languageRanges) Returns the language range in the specified collection that best matches the accept language header.
- Parameters:
languageRanges
- a collection of language ranges- Returns:
- an optional returning an accept match or an empty optional if no match was found
-
findBestMatch
default <T> Optional<Headers.AcceptMatch<Headers.AcceptLanguage.LanguageRange,T>> findBestMatch(Collection<T> items, Function<T, Headers.AcceptLanguage.LanguageRange> languageRangeExtractor) Returns the item from the specified collection whose language range best matches the accept language header.
- Type Parameters:
T
- the type of the item- Parameters:
items
- a collection of itemslanguageRangeExtractor
- a function that extracts the language range of an item- Returns:
- an optional returning an accept match or an empty optional if no match was found
-
findAllMatch
default Collection<Headers.AcceptMatch<Headers.AcceptLanguage.LanguageRange,Headers.AcceptLanguage.LanguageRange>> findAllMatch(Collection<Headers.AcceptLanguage.LanguageRange> languageRanges) Returns all the language ranges in the specified collection that matches the accept language header sorted from best to worst.
- Parameters:
languageRanges
- a collection of language ranges- Returns:
- a collection of accept matches
-
findAllMatch
default <T> Collection<Headers.AcceptMatch<Headers.AcceptLanguage.LanguageRange,T>> findAllMatch(Collection<T> items, Function<T, Headers.AcceptLanguage.LanguageRange> languageRangeExtractor) Returns all the items in the specified collection whose language range matches the accept language header sorted from best to worst.
- Type Parameters:
T
- the type of the item- Parameters:
items
- a collection of itemslanguageRangeExtractor
- a function that extracts the language range of an item- Returns:
- a collection of accept matches
-
merge
Merges multiple accept language headers into one.
- Parameters:
acceptLanguageHeaders
- a list of accept language headers.- Returns:
- an optional returning an accept language header or an empty optional if the specified list was null or empty
-