Skip to content

Refactor: Add null check, optimize string joining, and add JavaDocs #3663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

KoreaNirsa
Copy link
Contributor

Summary

This PR improves the getTextContent method in OpenAiApi with better performance, input validation, and complete documentation.

Changes

  • Assert.notNull(content, "content cannot be null") to prevent potential NullPointerException
  • .reduce("", (a, b) -> a + b) with .collect(Collectors.joining()) for O(n) string concatenation
  • JavaDocs with parameter/return/exception descriptions for better maintainability

@KoreaNirsa KoreaNirsa force-pushed the refactor/getTextContent-joining-and-null-check branch from 4f0489b to 399e419 Compare June 25, 2025 09:47
Copy link
Contributor

@sunyuhan1998 sunyuhan1998 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@yuluo-yx yuluo-yx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants