@Singleton public class BodyConverterSelector extends Object
Body.Parser
or Body.Formatter
using media
types.
. Examples:
// selector with html and json converters selector = new BodyConverterSelector(Sets.newLinkedHashSet(html, json)); // asking for html, produces the html converter assertEquals(html, selector.get(MediaType.html)); // asking for json, produces the json converter assertEquals(json, selector.get(MediaType.json)); // asking for * / *, produces the first matching converter assertEquals(html, selector.get(MediaType.all));
Constructor and Description |
---|
BodyConverterSelector(Set<Body.Parser> parsers,
Set<Body.Formatter> formatters)
Creates a new
BodyConverterSelector . |
Modifier and Type | Method and Description |
---|---|
Optional<Body.Parser> |
forRead(com.google.inject.TypeLiteral<?> type,
Iterable<MediaType> types) |
Optional<Body.Formatter> |
forWrite(Object message,
Iterable<MediaType> types) |
List<MediaType> |
viewableTypes() |
@Inject public BodyConverterSelector(Set<Body.Parser> parsers, Set<Body.Formatter> formatters)
BodyConverterSelector
.parsers
- The available body parsers in the system.formatters
- The available body formatters in the system.Copyright © 2014. All rights reserved.