xref: /aosp_15_r20/external/flatbuffers/tests/MyGame/Example/AnyUnion.java (revision 890232f25432b36107d06881e0a25aaa6b473652)
1 // automatically generated by the FlatBuffers compiler, do not modify
2 
3 package MyGame.Example;
4 
5 import com.google.flatbuffers.FlatBufferBuilder;
6 
7 public class AnyUnion {
8   private byte type;
9   private Object value;
10 
getType()11   public byte getType() { return type; }
12 
setType(byte type)13   public void setType(byte type) { this.type = type; }
14 
getValue()15   public Object getValue() { return value; }
16 
setValue(Object value)17   public void setValue(Object value) { this.value = value; }
18 
AnyUnion()19   public AnyUnion() {
20     this.type = Any.NONE;
21     this.value = null;
22   }
23 
asMonster()24   public MyGame.Example.MonsterT asMonster() { return (MyGame.Example.MonsterT) value; }
asTestSimpleTableWithEnum()25   MyGame.Example.TestSimpleTableWithEnumT asTestSimpleTableWithEnum() { return (MyGame.Example.TestSimpleTableWithEnumT) value; }
asMyGame_Example2_Monster()26   public MyGame.Example2.MonsterT asMyGame_Example2_Monster() { return (MyGame.Example2.MonsterT) value; }
27 
pack(FlatBufferBuilder builder, AnyUnion _o)28   public static int pack(FlatBufferBuilder builder, AnyUnion _o) {
29     switch (_o.type) {
30       case Any.Monster: return MyGame.Example.Monster.pack(builder, _o.asMonster());
31       case Any.TestSimpleTableWithEnum: return MyGame.Example.TestSimpleTableWithEnum.pack(builder, _o.asTestSimpleTableWithEnum());
32       case Any.MyGame_Example2_Monster: return MyGame.Example2.Monster.pack(builder, _o.asMyGame_Example2_Monster());
33       default: return 0;
34     }
35   }
36 }
37 
38