Source:
private AnalyzeSentimentResult convertToAnalyzeSentimentResult(DocumentSentiment documentSentiment) { final SentimentConfidenceScorePerLabel confidenceScorePerLabel = documentSentiment.getConfidenceScores(); final List<SentenceSentiment> sentenceSentiments = documentSentiment.getSentences().stream() .map(sentenceSentiment -> { final SentimentConfidenceScorePerLabel confidenceScorePerSentence = sentenceSentiment.getConfidenceScores(); return new SentenceSentiment(sentenceSentiment.getText(), sentenceSentiment.getSentiment().toString(), new SentimentConfidenceScores(confidenceScorePerSentence.getNegative(), confidenceScorePerSentence.getNeutral(), confidenceScorePerSentence.getPositive())); }).collect(Collectors.toList()); final List<TextAnalyticsWarning> warnings = documentSentiment.getWarnings().stream().map( warning -> new TextAnalyticsWarning(warning.getCode().toString(), warning.getMessage())).collect(Collectors.toList()); return new AnalyzeSentimentResult( documentSentiment.getId(), documentSentiment.getStatistics() == null ? null : toTextDocumentStatistics(documentSentiment.getStatistics()), null, new com.azure.ai.textanalytics.models.DocumentSentiment( documentSentiment.getSentiment().toString(), new SentimentConfidenceScores( confidenceScorePerLabel.getNegative(), confidenceScorePerLabel.getNeutral(), confidenceScorePerLabel.getPositive()), new IterableStream<>(sentenceSentiments), new IterableStream<>(warnings))); }

Target:
private AnalyzeSentimentResult convertToAnalyzeSentimentResult(DocumentSentiment documentSentiment) { final SentimentConfidenceScorePerLabel confidenceScorePerLabel = documentSentiment.getConfidenceScores(); final List<SentenceSentiment> sentenceSentiments = documentSentiment.getSentences().stream() .map(sentenceSentiment -> { final SentimentConfidenceScorePerLabel confidenceScorePerSentence = sentenceSentiment.getConfidenceScores(); final SentenceSentimentValue sentenceSentimentValue = sentenceSentiment.getSentiment(); return new SentenceSentiment(sentenceSentiment.getText(), sentenceSentimentValue == null ? null : sentenceSentimentValue.toString(), new SentimentConfidenceScores(confidenceScorePerSentence.getNegative(), confidenceScorePerSentence.getNeutral(), confidenceScorePerSentence.getPositive())); }).collect(Collectors.toList()); final List<TextAnalyticsWarning> warnings = documentSentiment.getWarnings().stream().map( warning -> { final WarningCodeValue warningCodeValue = warning.getCode(); return new TextAnalyticsWarning(warningCodeValue == null ? null : warningCodeValue.toString(), warning.getMessage()); }).collect(Collectors.toList()); final DocumentSentimentValue documentSentimentValue = documentSentiment.getSentiment(); return new AnalyzeSentimentResult( documentSentiment.getId(), documentSentiment.getStatistics() == null ? null : toTextDocumentStatistics(documentSentiment.getStatistics()), null, new com.azure.ai.textanalytics.models.DocumentSentiment( documentSentimentValue == null ? null : documentSentimentValue.toString(), new SentimentConfidenceScores( confidenceScorePerLabel.getNegative(), confidenceScorePerLabel.getNeutral(), confidenceScorePerLabel.getPositive()), new IterableStream<>(sentenceSentiments), new IterableStream<>(warnings))); }