If you add the "beans" option to the Java generator like this:
thrift --gen java:beans file.thrift |
Thrift will generate WikiPedia:JavaBean style classes.
private
.Each generated Bean class has public field named __isset
, which is an instance of a nested class named Isset
.
Each member field in the parent class has a corresponding public boolean
field in the Isset
class with the same name.
__isset
fields.__isset
field.__isset
field is false
will be omitted from the serialized output.
__isset
is necessary because Java primitives cannot be null
. See discussion of THRIFT-33.
See the Thrift Whitepaper for more information on the Isset class.