bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
indent(f_struct) <<
- "public " << (is_final ? "final " : "") << "class " << tstruct->get_name()
- << " extends TUnion<" << tstruct->get_name() << "._Fields> ";
-
- f_struct << "implements Comparable<" << type_name(tstruct) << "> ";
+ "public " << (is_final ? "final " : "") << "class " << tstruct->get_name()
+ << " extends TUnion<" << tstruct->get_name() << ", " << tstruct->get_name() << "._Fields> ";
scope_up(f_struct);
if (is_exception) {
out << "extends Exception ";
}
- out << "implements TBase<" << tstruct->get_name() << "._Fields>, java.io.Serializable, Cloneable";
-
- out << ", Comparable<" << type_name(tstruct) << ">";
+ out << "implements TBase<" << tstruct->get_name() << ", " << tstruct->get_name() << "._Fields>, java.io.Serializable, Cloneable";
out << " ";
* Generic base interface for generated Thrift objects.
*
*/
-public interface TBase<F extends TFieldIdEnum> extends Serializable {
+public interface TBase<T extends TBase, F extends TFieldIdEnum> extends Comparable<T>, Serializable {
/**
* Reads the TObject from the given input protocol.
*/
public void setFieldValue(F field, Object value);
- public TBase<F> deepCopy();
+ public TBase<T, F> deepCopy();
}
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.protocol.TStruct;
-public abstract class TUnion<F extends TFieldIdEnum> implements TBase<F> {
+public abstract class TUnion<T extends TUnion, F extends TFieldIdEnum> implements TBase<T, F> {
protected Object value_;
protected F setField_;
setFieldValue(setField, value);
}
- protected TUnion(TUnion<F> other) {
+ protected TUnion(TUnion<T, F> other) {
if (!other.getClass().equals(this.getClass())) {
throw new ClassCastException();
}