Skip to content

vicboma1/CommandMapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CommandMap Design Pattern - Behavioral

Build Status Coverage Status Maven Central Analytics

The CommandMapper class implements a domain specific language (DSL) with next interfaces:

CommandCollection
CommandConfigurator
CommandDictionary
CommandExecutable
CommandUnmapper

which provides one method for mapping commands and they are run asynchronously or synchronously.

Manual

Statements

final CommandMapperDictionary commandMapperDictionary = CommandMapperDictionaryImpl.create(Executors.newSingleThreadExecutor());
final CommandMapper commandMapper = CommandMapper.create(commandMapperDictionary);

Configuration

this.commandMapper.one(true);  //only one execution by command

Add Command Runnable

final String command = "commandRunnable";
final Runnable runnable = (Runnable) () -> { ... };
commandMapper.addCommand(command,runnable);

Add Command Callable

final String command = "commandCalable";
final Callable<T> callable = (Callable<T>) () -> { ...  return (T)... ; };
commandMapper.addCommand(command,callable);

Execute Command

final String command = e.getActionCommand();
final T valueCompleted = commandMapper.execute(command);   

ExecuteAsync Command

final String command = e.getActionCommand();
final CompletableFuture<T> completed = commandMapper.execute(command);   //Here, the promise is in second plane.
T value = completed.get();    // Waiting to resolution of the promise

UnMapper Command

final String command = e.getActionCommand();
commandMapper.unMapper(command);

UnMapperAll Commands

commandMapper.unMapperAll();

Register Commands

final int size = commandMapper.size();

About

Behaviour Design Pattern

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages