Encoders extends MediaTypeCodecs<Encoder> { public Encoder acceptedEncoder(CharSequence accept) { if (accept == null) { return defaultValue(); } String[] contentTypes = CONTENT_TYPE_DELIMITER.split(accept); for (String contentType : contentTypes) { String[] parts = PARAM_DELIMITER.split(contentType); Encoder encoder = get(parts[0]); if (encoder != null) { return encoder; } } return defaultValue(); } @Builder private  Encoders(CharSequence defaultContentType, @Singular ImmutableList<Encoder> encoders); Encoder acceptedEncoder(CharSequence accept);  }
@Test void testDefaultEncoder() { assertSame(jsonEncoder, encoders.acceptedEncoder("")); }
@Test void testDefaultEncoderForNull() { assertSame(jsonEncoder, encoders.acceptedEncoder(null)); }
@Test void testEncoderWithoutParam() { assertSame(fooBarEncoder, encoders.acceptedEncoder("text/plain, foo/bar")); }
@Test void testEncoderWithParam() { assertSame(fooBarEncoder, encoders.acceptedEncoder("foo/bar; q=6, text/plain; q=5")); }