- All Superinterfaces:
Header
- Enclosing class:
Headers
Accept HTTP header as defined by RFC 7231 Section 5.3.2.
- Since:
- 1.0
- Author:
- Jeremy Kuhn
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Accept HTTP header media range as defined by RFC 7231 Section 5.3.2. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionfindAllMatch
(Collection<Headers.ContentType> contentTypes) Returns all the content types in the specified collection that matches the accept header sorted from best to worst.default <T> Collection
<Headers.AcceptMatch<Headers.Accept.MediaRange, T>> findAllMatch
(Collection<T> items, Function<T, Headers.ContentType> contentTypeExtractor) Returns all the items in the specified collection whose content type matches the accept header sorted from best to worst.findBestMatch
(Collection<Headers.ContentType> contentTypes) Returns the content type in the specified collection that best matches the accept header.default <T> Optional
<Headers.AcceptMatch<Headers.Accept.MediaRange, T>> findBestMatch
(Collection<T> items, Function<T, Headers.ContentType> contentTypeExtractor) Returns the item from the specified collection whose content type best matches the accept header.Returns the list of media ranges defined in the accept header.static Optional
<Headers.Accept> merge
(List<Headers.Accept> acceptHeaders) Merges multiple accept headers into one.Methods inherited from interface io.inverno.mod.http.base.header.Header
getHeaderName, getHeaderValue
-
Field Details
-
ALL
Accept all header: */*
-
-
Method Details
-
getMediaRanges
List<Headers.Accept.MediaRange> getMediaRanges()Returns the list of media ranges defined in the accept header.
- Returns:
- a list of media ranges
-
findBestMatch
default Optional<Headers.AcceptMatch<Headers.Accept.MediaRange,Headers.ContentType>> findBestMatch(Collection<Headers.ContentType> contentTypes) Returns the content type in the specified collection that best matches the accept header.
- Parameters:
contentTypes
- a collection of content types- Returns:
- an optional returning an accept match or an empty optional if no match was found
-
findBestMatch
default <T> Optional<Headers.AcceptMatch<Headers.Accept.MediaRange,T>> findBestMatch(Collection<T> items, Function<T, Headers.ContentType> contentTypeExtractor) Returns the item from the specified collection whose content type best matches the accept header.
- Type Parameters:
T
- the type of the item- Parameters:
items
- a collection itemscontentTypeExtractor
- a function that extracts the content type 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.Accept.MediaRange,Headers.ContentType>> findAllMatch(Collection<Headers.ContentType> contentTypes) Returns all the content types in the specified collection that matches the accept header sorted from best to worst.
- Parameters:
contentTypes
- a collection of content types- Returns:
- a collection of accept matches
-
findAllMatch
default <T> Collection<Headers.AcceptMatch<Headers.Accept.MediaRange,T>> findAllMatch(Collection<T> items, Function<T, Headers.ContentType> contentTypeExtractor) Returns all the items in the specified collection whose content type matches the accept header sorted from best to worst.
- Type Parameters:
T
- the type of the item- Parameters:
items
- a collection of itemscontentTypeExtractor
- a function that extracts the content type of an item- Returns:
- a collection of accept matches
-
merge
Merges multiple accept headers into one.
- Parameters:
acceptHeaders
- a list of accept headers.- Returns:
- an optional returning an accept header or an empty optional if the specified list was null or empty
-