Source:
private Response<RecognizePiiEntitiesResultCollection> toRecognizePiiEntitiesResultCollectionResponse( final Response<EntitiesResult> response) { final EntitiesResult entitiesResult = response.getValue(); final List<RecognizePiiEntitiesResult> recognizeEntitiesResults = new ArrayList<>(); entitiesResult.getDocuments().forEach(documentEntities -> recognizeEntitiesResults.add(new RecognizePiiEntitiesResult( documentEntities.getId(), documentEntities.getStatistics() == null ? null : toTextDocumentStatistics(documentEntities.getStatistics()), null, new PiiEntityCollection( new IterableStream<>(documentEntities.getEntities().stream().map(entity -> new PiiEntity(entity.getText(), EntityCategory.fromString(entity.getCategory()), entity.getSubcategory(), entity.getOffset(), entity.getLength(), entity.getConfidenceScore())) .collect(Collectors.toList())), new IterableStream<>(documentEntities.getWarnings().stream() .map(warning -> { final WarningCodeValue warningCodeValue = warning.getCode(); return new TextAnalyticsWarning( WarningCode.fromString(warningCodeValue == null ? null : warningCodeValue.toString()), warning.getMessage()); }).collect(Collectors.toList()))) ))); entitiesResult.getErrors().forEach(documentError -> { if (documentError.getId().isEmpty()) { throw logger.logExceptionAsError( new HttpResponseException(documentError.getError().getInnererror().getMessage(), getEmptyErrorIdHttpResponse(new SimpleResponse<>(response, response.getValue())), documentError.getError().getInnererror().getCode())); } recognizeEntitiesResults.add( new RecognizePiiEntitiesResult(documentError.getId(), null, toTextAnalyticsError(documentError.getError()), null)); }); return new SimpleResponse<>(response, new RecognizePiiEntitiesResultCollection(recognizeEntitiesResults, entitiesResult.getModelVersion(), entitiesResult.getStatistics() == null ? null : toBatchStatistics(entitiesResult.getStatistics()))); }

Target:
private Response<RecognizePiiEntitiesResultCollection> toRecognizePiiEntitiesResultCollectionResponse( final Response<EntitiesResult> response) { final EntitiesResult entitiesResult = response.getValue(); final List<RecognizePiiEntitiesResult> recognizeEntitiesResults = new ArrayList<>(); entitiesResult.getDocuments().forEach(documentEntities -> { final List<PiiEntity> piiEntities = documentEntities.getEntities().stream().map(entity -> new PiiEntity(entity.getText(), EntityCategory.fromString(entity.getCategory()), entity.getSubcategory(), entity.getConfidenceScore(), entity.getOffset(), entity.getLength())) .collect(Collectors.toList()); final List<TextAnalyticsWarning> warnings = documentEntities.getWarnings().stream() .map(warning -> { final WarningCodeValue warningCodeValue = warning.getCode(); return new TextAnalyticsWarning( WarningCode.fromString(warningCodeValue == null ? null : warningCodeValue.toString()), warning.getMessage()); }).collect(Collectors.toList()); recognizeEntitiesResults.add(new RecognizePiiEntitiesResult( documentEntities.getId(), documentEntities.getStatistics() == null ? null : toTextDocumentStatistics(documentEntities.getStatistics()), null, new PiiEntityCollection(new IterableStream<>(piiEntities), new IterableStream<>(warnings)) )); }); entitiesResult.getErrors().forEach(documentError -> { recognizeEntitiesResults.add( new RecognizePiiEntitiesResult(documentError.getId(), null, toTextAnalyticsError(documentError.getError()), null)); }); return new SimpleResponse<>(response, new RecognizePiiEntitiesResultCollection(recognizeEntitiesResults, entitiesResult.getModelVersion(), entitiesResult.getStatistics() == null ? null : toBatchStatistics(entitiesResult.getStatistics()))); }