File tree Expand file tree Collapse file tree
core/src/main/java/com/google/adk/sessions Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2424import java .util .Base64 ;
2525import java .util .List ;
2626import java .util .Optional ;
27+ import org .jspecify .annotations .Nullable ;
2728
2829/** Utility functions for session service. */
2930public final class SessionUtils {
@@ -53,7 +54,7 @@ public static Content encodeContent(Content content) {
5354 encodedParts .add (part );
5455 }
5556 }
56- return toContent (encodedParts , content .role ());
57+ return toContent (encodedParts , content .role (). orElse ( null ) );
5758 }
5859
5960 /** Decodes Base64-encoded inline blobs in content. */
@@ -79,13 +80,15 @@ public static Content decodeContent(Content content) {
7980 decodedParts .add (part );
8081 }
8182 }
82- return toContent (decodedParts , content .role ());
83+ return toContent (decodedParts , content .role (). orElse ( null ) );
8384 }
8485
8586 /** Builds content from parts and optional role. */
86- private static Content toContent (List <Part > parts , Optional < String > role ) {
87+ private static Content toContent (List <Part > parts , @ Nullable String role ) {
8788 Content .Builder contentBuilder = Content .builder ().parts (parts );
88- role .ifPresent (contentBuilder ::role );
89+ if (role != null ) {
90+ contentBuilder .role (role );
91+ }
8992 return contentBuilder .build ();
9093 }
9194}
You can’t perform that action at this time.
0 commit comments