xref: /aosp_15_r20/external/flatbuffers/tests/union_vector/GadgetUnion.java (revision 890232f25432b36107d06881e0a25aaa6b473652)
1 // automatically generated by the FlatBuffers compiler, do not modify
2 
3 import com.google.flatbuffers.FlatBufferBuilder;
4 
5 public class GadgetUnion {
6   private byte type;
7   private Object value;
8 
getType()9   public byte getType() { return type; }
10 
setType(byte type)11   public void setType(byte type) { this.type = type; }
12 
getValue()13   public Object getValue() { return value; }
14 
setValue(Object value)15   public void setValue(Object value) { this.value = value; }
16 
GadgetUnion()17   public GadgetUnion() {
18     this.type = Gadget.NONE;
19     this.value = null;
20   }
21 
asFallingTub()22   public FallingTubT asFallingTub() { return (FallingTubT) value; }
asHandFan()23   public HandFanT asHandFan() { return (HandFanT) value; }
24 
pack(FlatBufferBuilder builder, GadgetUnion _o)25   public static int pack(FlatBufferBuilder builder, GadgetUnion _o) {
26     switch (_o.type) {
27       case Gadget.FallingTub: return FallingTub.pack(builder, _o.asFallingTub());
28       case Gadget.HandFan: return HandFan.pack(builder, _o.asHandFan());
29       default: return 0;
30     }
31   }
32 }
33 
34