@SuppressWarnings("unchecked")
protected Map<Long, Object> convertRequestResultToEntities(RestOperations operations, RequestResult response) {
Object result = response.toEntity();
if (RestResultException.isExceptionResult(result)) {
throw new RestResultException(result);
}
Collection<Map<String, Object>> responseCollection = (Collection<Map<String, Object>>) result;
Map<Long, Object> mappedObjects = new HashMap<Long, Object>(responseCollection.size());
for (Map<String, Object> entry : responseCollection) {
if (RestResultException.isExceptionResult(entry)) {
throw new RestResultException(entry);
}
final Long batchId = getBatchId(entry);
final RequestResult subResult = RequestResult.extractFrom(entry);
RestOperations.RestOperation restOperation = operations.getOperation(batchId);
Object entity = restOperation.getResultConverter().convertFromRepresentation(subResult);