Skip to content

Commit fad1a15

Browse files
CokeLee777ehsavoie
andauthored
docs: fix extractTextFromMessage snippet to use record accessors (#713)
# Description Replace getParts()/getText() with record accessor methods parts()/text(), use typed Part<?> instead of raw Part, and remove redundant null check that is already enforced by Message's compact constructor. Signed-off-by: Chaemin Lee <akak640@gmail.com> Co-authored-by: Emmanuel Hugonnet <ehsavoie@users.noreply.github.com>
1 parent fb06d43 commit fad1a15

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,9 @@ public class WeatherAgentExecutorProducer {
219219

220220
private String extractTextFromMessage(Message message) {
221221
StringBuilder textBuilder = new StringBuilder();
222-
if (message.getParts() != null) {
223-
for (Part part : message.getParts()) {
224-
if (part instanceof TextPart textPart) {
225-
textBuilder.append(textPart.getText());
226-
}
222+
for (Part<?> part : message.parts()) {
223+
if (part instanceof TextPart textPart) {
224+
textBuilder.append(textPart.text());
227225
}
228226
}
229227
return textBuilder.toString();

0 commit comments

Comments
 (0)