mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-14 16:36:55 +00:00
[Kotlin] Improve field nullability based on (required) (#7658)
* [Kotlin] Only generate nullable return types if the field is not required * [Kotlin] Fix generated code formatting according to kotlin style guide Co-authored-by: Derek Bailey <derekbailey@google.com> Co-authored-by: Paulo Pinheiro <paulovictor.pinheiro@gmail.com>
This commit is contained in:
@@ -68,10 +68,14 @@ class Monster : Table() {
|
||||
false
|
||||
}
|
||||
}
|
||||
val name : String?
|
||||
val name : String
|
||||
get() {
|
||||
val o = __offset(10)
|
||||
return if (o != 0) __string(o + bb_pos) else null
|
||||
return if (o != 0) {
|
||||
__string(o + bb_pos)
|
||||
} else {
|
||||
throw AssertionError("No value for (required) field name")
|
||||
}
|
||||
}
|
||||
val nameAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(10, 1)
|
||||
fun nameInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 10, 1)
|
||||
|
||||
@@ -31,7 +31,11 @@ class Stat : Table() {
|
||||
val id : String?
|
||||
get() {
|
||||
val o = __offset(4)
|
||||
return if (o != 0) __string(o + bb_pos) else null
|
||||
return if (o != 0) {
|
||||
__string(o + bb_pos)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
val idAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(4, 1)
|
||||
fun idInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 4, 1)
|
||||
|
||||
Reference in New Issue
Block a user