// 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 { BinaryValue } from './binary-value.js';
import { BoolValue } from './bool-value.js';
import { Float64Value } from './float64-value.js';
import { Int64Value } from './int64-value.js';
import { NullValue } from './null-value.js';
import { StringValue } from './string-value.js';


export enum HttpParameterValue {
  NONE = 0,
  Int64Value = 1,
  BoolValue = 2,
  StringValue = 3,
  BinaryValue = 4,
  Float64Value = 5,
  NullValue = 6
}

export function unionToHttpParameterValue(
  type: HttpParameterValue,
  accessor: (obj:BinaryValue|BoolValue|Float64Value|Int64Value|NullValue|StringValue) => BinaryValue|BoolValue|Float64Value|Int64Value|NullValue|StringValue|null
): BinaryValue|BoolValue|Float64Value|Int64Value|NullValue|StringValue|null {
  switch(HttpParameterValue[type]) {
    case 'NONE': return null; 
    case 'Int64Value': return accessor(new Int64Value())! as Int64Value;
    case 'BoolValue': return accessor(new BoolValue())! as BoolValue;
    case 'StringValue': return accessor(new StringValue())! as StringValue;
    case 'BinaryValue': return accessor(new BinaryValue())! as BinaryValue;
    case 'Float64Value': return accessor(new Float64Value())! as Float64Value;
    case 'NullValue': return accessor(new NullValue())! as NullValue;
    default: return null;
  }
}

export function unionListToHttpParameterValue(
  type: HttpParameterValue, 
  accessor: (index: number, obj:BinaryValue|BoolValue|Float64Value|Int64Value|NullValue|StringValue) => BinaryValue|BoolValue|Float64Value|Int64Value|NullValue|StringValue|null, 
  index: number
): BinaryValue|BoolValue|Float64Value|Int64Value|NullValue|StringValue|null {
  switch(HttpParameterValue[type]) {
    case 'NONE': return null; 
    case 'Int64Value': return accessor(index, new Int64Value())! as Int64Value;
    case 'BoolValue': return accessor(index, new BoolValue())! as BoolValue;
    case 'StringValue': return accessor(index, new StringValue())! as StringValue;
    case 'BinaryValue': return accessor(index, new BinaryValue())! as BinaryValue;
    case 'Float64Value': return accessor(index, new Float64Value())! as Float64Value;
    case 'NullValue': return accessor(index, new NullValue())! as NullValue;
    default: return null;
  }
}
