import { IClass } from "../../matching/IClass" ; import { CommandPayload } from "../../commandCenter/api/CommandPayload" ; import { ICommand } from "../../commandCenter/api/ICommand" ; import { ICommandExecutor } from "../../commandCenter/api/ICommandExecutor" ; import { ICommandMapping } from "../../commandCenter/api/ICommandMapping" ; import { ICommandMappingList } from "../../commandCenter/api/ICommandMappingList" ; import { CommandMapping } from "../../commandCenter/impl/CommandMapping" ; import { IDirectCommandConfigurator } from "../../directCommandMap/dsl/IDirectCommandConfigurator" ; private export class DirectCommandMapper implements IDirectCommandConfigurator { private _mappings : ICommandMappingList ; private _mapping : ICommandMapping ; private _executor : ICommandExecutor ; private constructor ( executor , mappings , commandClass ) { this . _executor = executor ; this . _mappings = mappings ; this . _mapping = new CommandMapping ( commandClass ) ; this . _mapping . setFireOnce ( true ) ; this . _mappings . addMapping ( this . _mapping ) ; } inheritDoc public withGuards ( ... guards ) { this . _mapping . addGuards ( ... guards ) ; return this ; } inheritDoc public withHooks ( ... hooks ) { this . _mapping . addHooks ( ... hooks ) ; return this ; } inheritDoc public withPayloadInjection ( value = true ) { this . _mapping . setPayloadInjectionEnabled ( value ) ; return this ; } inheritDoc public execute ( payload ? ) { this . _executor . executeCommands ( this . _mappings . getList ( ) , payload ) ; } inheritDoc public map ( commandClass ) { return new DirectCommandMapper ( this . _executor , this . _mappings , commandClass ) ; } }