Package dk.mada.jaxrs.model.api
Class ContentSelector
java.lang.Object
dk.mada.jaxrs.model.api.ContentSelector
Selects content based on configuration.
Some requests or responses may contain multiple media-types.
The options parser-api-preferred-response-mediatypes and parser-api-preferred-reply-mediatypes can be used to control
which type is selected.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
The context of a content lookup.static enum
Location of the content to resolve. -
Field Summary
-
Constructor Summary
ConstructorDescriptionContentSelector
(List<Pattern> preferredRequestMediaTypes, List<Pattern> preferredResponseMediaTypes) Constructs a new selector instance. -
Method Summary
Modifier and TypeMethodDescriptionselectPreferredMediaType
(Collection<String> mediaTypes, ContentSelector.ContentContext context) Select preferred media type,
-
Field Details
-
PARSER_API_PREFERRED_REQUEST_MEDIATYPES
Preferred request media types option name. Not a super placement!- See Also:
-
PARSER_API_PREFERRED_RESPONSE_MEDIATYPES
Preferred response media types option name. Not a super placement!- See Also:
-
-
Constructor Details
-
ContentSelector
public ContentSelector(List<Pattern> preferredRequestMediaTypes, List<Pattern> preferredResponseMediaTypes) Constructs a new selector instance.- Parameters:
preferredRequestMediaTypes
- a list of patterns for matching request media typespreferredResponseMediaTypes
- a list of patterns for matching response media types
-
-
Method Details
-
selectPreferredMediaType
public Optional<String> selectPreferredMediaType(Collection<String> mediaTypes, ContentSelector.ContentContext context) Select preferred media type,- Parameters:
mediaTypes
- the possible media typescontext
- the selection context- Returns:
- the selected context
-