From d20a1d3619efa9edef51364d927bc9a78b37217f Mon Sep 17 00:00:00 2001 From: Bryan Duxbury Date: Sat, 7 Feb 2009 01:08:58 +0000 Subject: [PATCH] THRIFT-303. java: Changes to __isset interface This patch makes __isset always private and adds a method per field to set the __isset state when not using the bean-style generator. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@741805 13f79535-47bb-0310-9956-ffa450edef68 --- compiler/cpp/src/generate/t_java_generator.cc | 12 ++++++++++-- lib/java/src/org/apache/thrift/TBase.java | 6 +++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc index 347a014f..cee43adc 100644 --- a/compiler/cpp/src/generate/t_java_generator.cc +++ b/compiler/cpp/src/generate/t_java_generator.cc @@ -628,8 +628,8 @@ void t_java_generator::generate_java_struct_definition(ofstream &out, if (members.size() > 0) { out << endl << - indent() << "public final Isset __isset = new Isset();" << endl << - indent() << "public static final class Isset implements java.io.Serializable {" << endl; + indent() << "private final Isset __isset = new Isset();" << endl << + indent() << "private static final class Isset implements java.io.Serializable {" << endl; indent_up(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { indent(out) << @@ -1441,6 +1441,14 @@ void t_java_generator::generate_java_bean_boilerplate(ofstream& out, indent(out) << "return this.__isset." << field_name << ";" << endl; indent_down(); indent(out) << "}" << endl << endl; + + if(!bean_style_) { + indent(out) << "public void set" << cap_name << get_cap_name("isSet") << "(boolean value) {" << endl; + indent_up(); + indent(out) << "this.__isset." << field_name << " = value;" << endl; + indent_down(); + indent(out) << "}"; + } } } diff --git a/lib/java/src/org/apache/thrift/TBase.java b/lib/java/src/org/apache/thrift/TBase.java index ef4e323a..bf1dc38a 100644 --- a/lib/java/src/org/apache/thrift/TBase.java +++ b/lib/java/src/org/apache/thrift/TBase.java @@ -28,14 +28,14 @@ public interface TBase extends Cloneable { * @param oprot Output protocol */ public void write(TProtocol oprot) throws TException; - + /** * Check if a field is currently set or unset. * * @param fieldId The field's id tag as found in the IDL. */ public boolean isSet(int fieldId); - + /** * Get a field's value by id. Primitive types will be wrapped in the * appropriate "boxed" types. @@ -43,7 +43,7 @@ public interface TBase extends Cloneable { * @param fieldId The field's id tag as found in the IDL. */ public Object getFieldValue(int fieldId); - + /** * Set a field's value by id. Primitive types must be "boxed" in the * appropriate object wrapper type. -- 2.17.1