/** * Test if the route definition can consume a media type. * * @param type A media type to test. * @return True, if the route can consume the given media type. */ public boolean canConsume(final MediaType type) { return MediaType.matcher(Arrays.asList(type)).matches(consumes); }
@Override public Object parse(final TypeLiteral<?> type, final Context ctx) throws Throwable { MediaType ctype = ctx.type(); if (ctype.isAny()) { // */* return ctx.next(); } JavaType javaType = mapper.constructType(type.getType()); if (matcher.matches(ctype) && mapper.canDeserialize(javaType)) { return ctx .ifparam(values -> mapper.readValue(values.iterator().next(), javaType)) .ifbody(body -> mapper.readValue(body.bytes(), javaType)); } return ctx.next(); }
/** * Test if the route definition can consume a media type. * * @param type A media type to test. * @return True, if the route can consume the given media type. */ public boolean canConsume(final MediaType type) { return MediaType.matcher(Arrays.asList(type)).matches(consumes); }
@Override public Object parse(final TypeLiteral<?> type, final Context ctx) throws Throwable { MediaType ctype = ctx.type(); if (ctype.isAny()) { // */* return ctx.next(); } JavaType javaType = mapper.constructType(type.getType()); if (matcher.matches(ctype) && mapper.canDeserialize(javaType)) { return ctx .ifparam(values -> mapper.readValue(values.iterator().next(), javaType)) .ifbody(body -> mapper.readValue(body.bytes(), javaType)); } return ctx.next(); }
/** * Test if the route definition can consume a media type. * * @param types A media types to test. * @return True, if the route can produces the given media type. */ public boolean canProduce(final List<MediaType> types) { return MediaType.matcher(types).matches(produces); }
/** * Test if the route definition can consume a media type. * * @param type A media type to test. * @return True, if the route can consume the given media type. */ public boolean canConsume(final String type) { return MediaType.matcher(MediaType.valueOf(type)).matches(consumes); }
@Override public boolean accepts(final MediaType type) { if (matcher == null) { matcher = MediaType.matcher(produces); } return matcher.matches(type); }
@Override public boolean accepts(final MediaType type) { if (matcher == null) { matcher = MediaType.matcher(produces); } return matcher.matches(type); }
/** * Test if the route definition can consume a media type. * * @param types A media types to test. * @return True, if the route can produces the given media type. */ public boolean canProduce(final List<MediaType> types) { return MediaType.matcher(types).matches(produces); }
/** * Test if the route definition can consume a media type. * * @param type A media type to test. * @return True, if the route can consume the given media type. */ public boolean canConsume(final String type) { return MediaType.matcher(MediaType.valueOf(type)).matches(consumes); }