MessageBodyConverter.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:jaxrs-versioning 作者:
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
  if (!isVersioningSupported(context)) {
    context.proceed();
    return;
  }
  String targetVersion = Version.get(context);
  Object source = context.getEntity();
  if (source instanceof Collection) {
    context.setEntity(convertCollectionToLowerVersion(targetVersion, (Collection<?>)source));
  } else {
    mapper.map(source);
    context.setEntity(converter.convertToLowerVersion(targetVersion, source));
  }
  Type targetType = getVersionType(context.getGenericType(), targetVersion);
  context.setType(toClass(targetType));
  context.setGenericType(targetType);
  context.proceed();
  Version.unset(context);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号