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

/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */

import { FallingTub, FallingTubT } from './falling-tub.js';
import { HandFan, HandFanT } from './hand-fan.js';


export enum Gadget {
  NONE = 0,
  FallingTub = 1,
  HandFan = 2
}

export function unionToGadget(
  type: Gadget,
  accessor: (obj:FallingTub|HandFan) => FallingTub|HandFan|null
): FallingTub|HandFan|null {
  switch(Gadget[type]) {
    case 'NONE': return null; 
    case 'FallingTub': return accessor(new FallingTub())! as FallingTub;
    case 'HandFan': return accessor(new HandFan())! as HandFan;
    default: return null;
  }
}

export function unionListToGadget(
  type: Gadget, 
  accessor: (index: number, obj:FallingTub|HandFan) => FallingTub|HandFan|null, 
  index: number
): FallingTub|HandFan|null {
  switch(Gadget[type]) {
    case 'NONE': return null; 
    case 'FallingTub': return accessor(index, new FallingTub())! as FallingTub;
    case 'HandFan': return accessor(index, new HandFan())! as HandFan;
    default: return null;
  }
}
