// 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 { HttpError } from './http-error.js';
import { HttpQuery } from './http-query.js';
import { HttpQueryResult } from './http-query-result.js';
import { HttpResultSet } from './http-result-set.js';


export enum HttpCommand {
  NONE = 0,
  HttpQuery = 1,
  HttpResultSet = 2,
  HttpError = 3,
  HttpQueryResult = 4
}

export function unionToHttpCommand(
  type: HttpCommand,
  accessor: (obj:HttpError|HttpQuery|HttpQueryResult|HttpResultSet) => HttpError|HttpQuery|HttpQueryResult|HttpResultSet|null
): HttpError|HttpQuery|HttpQueryResult|HttpResultSet|null {
  switch(HttpCommand[type]) {
    case 'NONE': return null; 
    case 'HttpQuery': return accessor(new HttpQuery())! as HttpQuery;
    case 'HttpResultSet': return accessor(new HttpResultSet())! as HttpResultSet;
    case 'HttpError': return accessor(new HttpError())! as HttpError;
    case 'HttpQueryResult': return accessor(new HttpQueryResult())! as HttpQueryResult;
    default: return null;
  }
}

export function unionListToHttpCommand(
  type: HttpCommand, 
  accessor: (index: number, obj:HttpError|HttpQuery|HttpQueryResult|HttpResultSet) => HttpError|HttpQuery|HttpQueryResult|HttpResultSet|null, 
  index: number
): HttpError|HttpQuery|HttpQueryResult|HttpResultSet|null {
  switch(HttpCommand[type]) {
    case 'NONE': return null; 
    case 'HttpQuery': return accessor(index, new HttpQuery())! as HttpQuery;
    case 'HttpResultSet': return accessor(index, new HttpResultSet())! as HttpResultSet;
    case 'HttpError': return accessor(index, new HttpError())! as HttpError;
    case 'HttpQueryResult': return accessor(index, new HttpQueryResult())! as HttpQueryResult;
    default: return null;
  }
}
