private static <K, V extends RecordTemplate> DataMap buildDataMap(Map<K, V> recordTemplates,
Map<K, ErrorResponse> errorResponses,
ProtocolVersion version)
{
DataMap batchResponseDataMap = new DataMap();
DataMap rawBatchData = new DataMap();
for (Map.Entry<K, V> entry : recordTemplates.entrySet())
{
String stringKey = URIParamUtils.encodeKeyForBody(entry.getKey(), false, version);
rawBatchData.put(stringKey, entry.getValue().data());
}
batchResponseDataMap.put(BatchResponse.RESULTS, rawBatchData);
DataMap rawErrorData = new DataMap();
for (Map.Entry<K, ErrorResponse> errorResponse : errorResponses.entrySet())
{
rawErrorData.put(String.valueOf(errorResponse.getKey()), errorResponse.getValue().data());
}
batchResponseDataMap.put(BatchResponse.ERRORS, rawErrorData);
return batchResponseDataMap;
}