@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void writeTo(Optional<?> entity,
Class<?> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream)
throws IOException {
if (!entity.isPresent()) {
throw new NotFoundException();
}
final Type innerGenericType = (genericType instanceof ParameterizedType) ?
((ParameterizedType) genericType).getActualTypeArguments()[0] : entity.get().getClass();
MessageBodyWriter writer = mbw.get().getMessageBodyWriter(entity.get().getClass(),
innerGenericType, annotations, mediaType);
writer.writeTo(entity.get(), entity.get().getClass(),
innerGenericType, annotations, mediaType, httpHeaders, entityStream);
}
OptionalMessageBodyWriter.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:dropwizard-java8
作者:
评论列表
文章目录