Skip to content

Commit c139938

Browse files
committed
Add description for the simpleNameFromSerialName function
1 parent 02d67c5 commit c139938

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

firebase-vertexai/src/test/java/com/google/firebase/vertexai/common/util/descriptorToJson.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,22 @@ internal fun typeNameFromKind(kind: SerialKind): String {
138138
}
139139
}
140140

141+
/**
142+
* Extracts the name expected for a class from its serial name.
143+
*
144+
* Our serialization classes are nested within the public-facing classes, and that's the name we
145+
* want in the json output. There are two class names
146+
*
147+
* - `com.google.firebase.vertexai.type.Content.Internal` for regular scenarios
148+
* - `com.google.firebase.vertexai.type.Content.Internal.SomeClass` for nested classes in the
149+
* serializer.
150+
*
151+
* For the later time we need the second to last component, for the former we need the last
152+
* component.
153+
*
154+
* Additionally, given that types can be nullable, we need to strip the `?` from the end of the
155+
* name.
156+
*/
141157
internal fun simpleNameFromSerialName(serialName: String): String =
142158
serialName
143159
.split(".")

0 commit comments

Comments
 (0)