/* tslint:disable */ /* eslint-disable */ /* * Autogenerated by @creditkarma/thrift-typescript v3.7.2 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING */ import * as thrift from 'thrift'; import * as MicroSeconds from './MicroSeconds'; import * as MilliSeconds from './MilliSeconds'; export interface ITimeUnitArgs { MILLIS?: MilliSeconds.MilliSeconds; MICROS?: MicroSeconds.MicroSeconds; } export class TimeUnit { public MILLIS?: MilliSeconds.MilliSeconds; public MICROS?: MicroSeconds.MicroSeconds; constructor(args?: ITimeUnitArgs) { let _fieldsSet: number = 0; if (args != null) { if (args.MILLIS != null) { _fieldsSet++; this.MILLIS = args.MILLIS; } if (args.MICROS != null) { _fieldsSet++; this.MICROS = args.MICROS; } if (_fieldsSet > 1) { throw new thrift.Thrift.TProtocolException( thrift.Thrift.TProtocolExceptionType.INVALID_DATA, 'Cannot read a TUnion with more than one set value!' ); } else if (_fieldsSet < 1) { throw new thrift.Thrift.TProtocolException( thrift.Thrift.TProtocolExceptionType.INVALID_DATA, 'Cannot read a TUnion with no set value!' ); } } } public static fromMILLIS(MILLIS: MilliSeconds.MilliSeconds): TimeUnit { return new TimeUnit({MILLIS}); } public static fromMICROS(MICROS: MicroSeconds.MicroSeconds): TimeUnit { return new TimeUnit({MICROS}); } public write(output: thrift.TProtocol): void { output.writeStructBegin('TimeUnit'); if (this.MILLIS != null) { output.writeFieldBegin('MILLIS', thrift.Thrift.Type.STRUCT, 1); this.MILLIS.write(output); output.writeFieldEnd(); } if (this.MICROS != null) { output.writeFieldBegin('MICROS', thrift.Thrift.Type.STRUCT, 2); this.MICROS.write(output); output.writeFieldEnd(); } output.writeFieldStop(); output.writeStructEnd(); return; } public static read(input: thrift.TProtocol): TimeUnit { let _fieldsSet: number = 0; let _returnValue: TimeUnit | null = null; input.readStructBegin(); while (true) { const ret: thrift.TField = input.readFieldBegin(); const fieldType: thrift.Thrift.Type = ret.ftype; const fieldId: number = ret.fid; if (fieldType === thrift.Thrift.Type.STOP) { break; } switch (fieldId) { case 1: if (fieldType === thrift.Thrift.Type.STRUCT) { _fieldsSet++; const value_1: MilliSeconds.MilliSeconds = MilliSeconds.MilliSeconds.read(input); _returnValue = TimeUnit.fromMILLIS(value_1); } else { input.skip(fieldType); } break; case 2: if (fieldType === thrift.Thrift.Type.STRUCT) { _fieldsSet++; const value_2: MicroSeconds.MicroSeconds = MicroSeconds.MicroSeconds.read(input); _returnValue = TimeUnit.fromMICROS(value_2); } else { input.skip(fieldType); } break; default: { input.skip(fieldType); } } input.readFieldEnd(); } input.readStructEnd(); if (_fieldsSet > 1) { throw new thrift.Thrift.TProtocolException( thrift.Thrift.TProtocolExceptionType.INVALID_DATA, 'Cannot read a TUnion with more than one set value!' ); } else if (_fieldsSet < 1) { throw new thrift.Thrift.TProtocolException( thrift.Thrift.TProtocolExceptionType.INVALID_DATA, 'Cannot read a TUnion with no set value!' ); } if (_returnValue !== null) { return _returnValue; } else { throw new thrift.Thrift.TProtocolException( thrift.Thrift.TProtocolExceptionType.UNKNOWN, 'Unable to read data for TUnion' ); } } }