Skip to content

Conversation

eeaters
Copy link
Contributor

@eeaters eeaters commented Sep 2, 2025

  • Replace if-else null checks with Optional chain
  • Improve code readability and maintain functional style

Since ChatResponse::getResult equals ChatResponse.getResults().get(0), the else code block is unreachable.
Optimized the code to improve readability.

eeaters and others added 3 commits September 2, 2025 14:44
- Replace if-else null checks with Optional chain
- Improve code readability and maintain functional style

Signed-off-by: eeaters <[email protected]>
Signed-off-by: YuJie Wan <[email protected]>
sobychacko added a commit to sobychacko/spring-ai that referenced this pull request Sep 18, 2025
Replace nested null checks and redundant branching with streamlined
Optional-based approach. Since getResult() == getResults().get(0),
processing all results handles both single and multiple result cases.

Fixes spring-projects#4292

Signed-off-by: Soby Chacko <[email protected]>
sobychacko added a commit to sobychacko/spring-ai that referenced this pull request Sep 19, 2025
Replace nested null checks and redundant branching with streamlined
Optional-based approach. Since getResult() == getResults().get(0),
processing all results handles both single and multiple result cases.

Adding tests to verify.

Fixes spring-projects#4292

Signed-off-by: Soby Chacko <[email protected]>
ilayaperumalg pushed a commit that referenced this pull request Sep 22, 2025
Replace nested null checks and redundant branching with streamlined
Optional-based approach. Since getResult() == getResults().get(0),
processing all results handles both single and multiple result cases.

Adding tests to verify.

Fixes #4292

Co-Authored-By: eeaters <[email protected]>
Signed-off-by: Soby Chacko <[email protected]>
@ilayaperumalg
Copy link
Member

@eeaters Thanks for your PR. Merged the changes from @sobychacko on top of your proposal. Made sure to add you as the co-author to the merged commit.

@ilayaperumalg ilayaperumalg self-assigned this Sep 22, 2025
@ilayaperumalg ilayaperumalg added this to the 1.1.0.M2 milestone Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants