class JaxrsConsumerResponseMapper implements ConsumerResponseMapper {

  @Override
  public Object mapResponse(Response response) {
    ResponseBuilder responseBuilder =
        javax.ws.rs.core.Response.status(response.getStatus()).entity(response.getResult());

    Map<String, List<Object>> headers = response.getHeaders().getHeaderMap();
    if (headers == null) {
      return responseBuilder.build();
    }

    for (Entry<String, List<Object>> entry : headers.entrySet()) {
      if (entry.getValue() == null) {
        continue;
      }

      for (Object value : entry.getValue()) {
        if (value != null) {
          responseBuilder.header(entry.getKey(), value);
        }
      }
    }

    return responseBuilder.build();
  }

}