To read the optional field foo in Kotlin:
Because the generated codes are like:
@java.lang.Override
public boolean hasFoo() { ... }
@java.lang.Override
public long getFoo() { ... }
We need to bar.foo.takeIf { bar.hasFoo() }, which is not Kotlin-friendly. It's expected to add @Nullable or @NotNull to getter methods.