@Test public void isAccepted() { HashRequestHeaders hs = withHeader(Http.Header.ACCEPT, "text/*;q=0.3, application/json;q=0.7"); assertThat(hs.isAccepted(MediaType.TEXT_HTML), is(true)); assertThat(hs.isAccepted(MediaType.TEXT_XML), is(true)); assertThat(hs.isAccepted(MediaType.APPLICATION_JSON), is(true)); assertThat(hs.isAccepted(MediaType.APPLICATION_OCTET_STREAM), is(false)); }
@Override public boolean isAccepted(MediaType mediaType) { Objects.requireNonNull(mediaType, "Parameter 'mediaType' is null!"); List<MediaType> acceptedTypes = acceptedTypes(); return acceptedTypes.isEmpty() || acceptedTypes.stream().anyMatch(mediaType); }
HashRequestHeaders extends ReadOnlyParameters implements RequestHeaders { @Override public boolean isAccepted(MediaType mediaType) { Objects.requireNonNull(mediaType, "Parameter 'mediaType' is null!"); List<MediaType> acceptedTypes = acceptedTypes(); return acceptedTypes.isEmpty() || acceptedTypes.stream().anyMatch(mediaType); } }
HashRequestHeaders extends ReadOnlyParameters implements RequestHeaders { @Override public boolean isAccepted(MediaType mediaType) { Objects.requireNonNull(mediaType, "Parameter 'mediaType' is null!"); List<MediaType> acceptedTypes = acceptedTypes(); return acceptedTypes.isEmpty() || acceptedTypes.stream().anyMatch(mediaType); } HashRequestHeaders();   HashRequestHeaders(Map<String, List<String>> initialContent); }
HashRequestHeaders extends ReadOnlyParameters implements RequestHeaders { @Override public boolean isAccepted(MediaType mediaType) { Objects.requireNonNull(mediaType, "Parameter 'mediaType' is null!"); List<MediaType> acceptedTypes = acceptedTypes(); return acceptedTypes.isEmpty() || acceptedTypes.stream().anyMatch(mediaType); } HashRequestHeaders();   HashRequestHeaders(Map<String, List<String>> initialContent); @Override Optional<MediaType> contentType(); @Override OptionalLong contentLength(); @Override Parameters cookies(); @Override List<MediaType> acceptedTypes(); @Override boolean isAccepted(MediaType mediaType); @Override Optional<MediaType> bestAccepted(MediaType... mediaTypes); @Override Optional<ZonedDateTime> acceptDatetime(); @Override Optional<ZonedDateTime> date(); @Override Optional<ZonedDateTime> ifModifiedSince(); @Override Optional<ZonedDateTime> ifUnmodifiedSince(); @Override Optional<URI> referer(); }
HashRequestHeaders extends ReadOnlyParameters implements RequestHeaders { @Override public boolean isAccepted(MediaType mediaType) { Objects.requireNonNull(mediaType, "Parameter 'mediaType' is null!"); List<MediaType> acceptedTypes = acceptedTypes(); return acceptedTypes.isEmpty() || acceptedTypes.stream().anyMatch(mediaType); } HashRequestHeaders();   HashRequestHeaders(Map<String, List<String>> initialContent); @Override Optional<MediaType> contentType(); @Override OptionalLong contentLength(); @Override Parameters cookies(); @Override List<MediaType> acceptedTypes(); @Override boolean isAccepted(MediaType mediaType); @Override Optional<MediaType> bestAccepted(MediaType... mediaTypes); @Override Optional<ZonedDateTime> acceptDatetime(); @Override Optional<ZonedDateTime> date(); @Override Optional<ZonedDateTime> ifModifiedSince(); @Override Optional<ZonedDateTime> ifUnmodifiedSince(); @Override Optional<URI> referer();  }