// automatically generated by the FlatBuffers compiler, do not modify

import { Monster as MyGameExample2Monster, MonsterT as MyGameExample2MonsterT } from '../../my-game/example2/monster';
import { Monster, MonsterT } from '../../my-game/example/monster';
import { TestSimpleTableWithEnum, TestSimpleTableWithEnumT } from '../../my-game/example/test-simple-table-with-enum';


export enum Any{
  NONE = 0,
  Monster = 1,
  TestSimpleTableWithEnum = 2,
  MyGame_Example2_Monster = 3
}

export function unionToAny(
  type: Any,
  accessor: (obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null
): Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null {
  switch(Any[type]) {
    case 'NONE': return null; 
    case 'Monster': return accessor(new Monster())! as Monster;
    case 'TestSimpleTableWithEnum': return accessor(new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
    case 'MyGame_Example2_Monster': return accessor(new MyGameExample2Monster())! as MyGameExample2Monster;
    default: return null;
  }
}

export function unionListToAny(
  type: Any, 
  accessor: (index: number, obj:Monster|MyGameExample2Monster|TestSimpleTableWithEnum) => Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null, 
  index: number
): Monster|MyGameExample2Monster|TestSimpleTableWithEnum|null {
  switch(Any[type]) {
    case 'NONE': return null; 
    case 'Monster': return accessor(index, new Monster())! as Monster;
    case 'TestSimpleTableWithEnum': return accessor(index, new TestSimpleTableWithEnum())! as TestSimpleTableWithEnum;
    case 'MyGame_Example2_Monster': return accessor(index, new MyGameExample2Monster())! as MyGameExample2Monster;
    default: return null;
  }
}

