@Override
  @SuppressWarnings("unchecked")
  public PartialRestResponse buildResponse(
      RoutingResult routingResult, RestLiResponseData responseData) {
    List<CreateCollectionResponseEnvelope.CollectionCreateResponseItem> collectionCreateResponses =
        responseData.getCreateCollectionResponseEnvelope().getCreateResponses();
    List<CreateIdStatus<Object>> formattedResponses =
        new ArrayList<CreateIdStatus<Object>>(collectionCreateResponses.size());

    // Iterate through the responses and generate the ErrorResponse with the appropriate override
    // for exceptions.
    // Otherwise, add the result as is.
    for (CreateCollectionResponseEnvelope.CollectionCreateResponseItem response :
        collectionCreateResponses) {
      if (response.isErrorResponse()) {
        RestLiServiceException exception = response.getException();
        formattedResponses.add(
            new CreateIdStatus<Object>(
                exception.getStatus().getCode(),
                response.getId(),
                _errorResponseBuilder.buildErrorResponse(exception),
                ProtocolVersionUtil.extractProtocolVersion(responseData.getHeaders())));
      } else {
        if (response.getRecord() instanceof CreateIdEntityStatus) {
          CreateIdEntityStatus<?, ?> currentStatus =
              (CreateIdEntityStatus<?, ?>) response.getRecord();
          final ResourceContext resourceContext = routingResult.getContext();
          DataMap entityData =
              currentStatus.getEntity() != null ? currentStatus.getEntity().data() : null;
          final DataMap data =
              RestUtils.projectFields(
                  entityData,
                  resourceContext.getProjectionMode(),
                  resourceContext.getProjectionMask());
          CreateIdEntityStatus<?, ?> projectedStatus =
              new CreateIdEntityStatus(
                  currentStatus.getStatus(),
                  currentStatus.getKey(),
                  new AnyRecord(data),
                  currentStatus.getError(),
                  ProtocolVersionUtil.extractProtocolVersion(resourceContext.getRequestHeaders()));
          formattedResponses.add((CreateIdStatus<Object>) projectedStatus);
        } else {
          formattedResponses.add((CreateIdStatus<Object>) response.getRecord());
        }
      }
    }

    PartialRestResponse.Builder builder = new PartialRestResponse.Builder();
    BatchCreateIdResponse<Object> batchCreateIdResponse =
        new BatchCreateIdResponse<Object>(formattedResponses);
    return builder
        .headers(responseData.getHeaders())
        .cookies(responseData.getCookies())
        .entity(batchCreateIdResponse)
        .build();
  }
 @Override
 public Object[] buildArguments(RestLiRequestData requestData, RoutingResult routingResult) {
   return ArgumentBuilder.buildArgs(
       new Object[0], routingResult.getResourceMethod(), routingResult.getContext(), null);
 }