import { EnumTypeConfig , Options } from '../types' ; import { ODataSchemaElement } from './element' ; import { ODataEnumTypeFieldParser , ODataEnumTypeParser } from './parsers' ; import { ODataSchema } from './schema' ; export class ODataEnumType < E > extends ODataSchemaElement { parser : ODataEnumTypeParser < E > ; members : { [ name ] : number ; } | { [ value ] : string ; } ; constructor ( config , schema ) { super ( config , schema ) ; this . members = config . members ; this . parser = new ODataEnumTypeParser < E > ( config , schema . namespace , schema . alias ) ; } configure ( ) { this . parser . configure ( { options : this . api . options } ) ; } returns fields ( ) { return this . parser . fields ; } param name returns findFieldByName ( name ) { return this . fields ( ) . find ( ( f ) => f . name === name ) ; } param value returns findFieldByValue ( value ) { return this . fields ( ) . find ( ( f ) => f . value === value ) ; } param mapper returns mapFields < T > ( mapper ) { return this . fields ( ) . map ( mapper ) ; } param value param options returns deserialize ( value , options ? ) { return this . parser . deserialize ( value , options ) ; } param value param options returns serialize ( value , options ? ) { return this . parser . serialize ( value , options ) ; } param value param options returns encode ( value , options ? ) { return this . parser . encode ( value , options ) ; } }