import { IFunctionCallArgument } from './IFunctionCallArgument' ; import { IFunctionCallArgumentCollection } from './IFunctionCallArgumentCollection' ; export class FunctionCallArgumentCollection implements IFunctionCallArgumentCollection { private readonly arguments = new Map < string , IFunctionCallArgument > ( ) ; public addArgument ( argument ) { if ( ! argument ) { throw new Error ( 'undefined argument' ) ; } if ( this . hasArgument ( argument . parameterName ) ) { throw new Error ( `argument value for parameter ${ argument . parameterName } is already provided` ) ; } this . arguments . set ( argument . parameterName , argument ) ; } public getAllParameterNames ( ) { return Array . from ( this . arguments . keys ( ) ) ; } public hasArgument ( parameterName ) { if ( ! parameterName ) { throw new Error ( 'undefined parameter name' ) ; } return this . arguments . has ( parameterName ) ; } public getArgument ( parameterName ) { if ( ! parameterName ) { throw new Error ( 'undefined parameter name' ) ; } const arg = this . arguments . get ( parameterName ) ; if ( ! arg ) { throw new Error ( `parameter does not exist: ${ parameterName }` ) ; } return arg ; } }