InterceptedCommand class

Implements a ICommand command wrapped by an interceptor. It allows to build command call chains. The interceptor can alter execution and delegate calls to a next command, which can be intercepted or concrete. See ICommand See ICommandInterceptor

Example

class CommandLogger implements ICommandInterceptor {
    String getName(ICommand command) {
        return command.getName();
    }
    void execute(String correlationId, ICommand command , Parameters args,) async {
        print('Executed command ' + command.getName());
        return await command.execute(correlationId, args);
    }
    List<ValidationResult> validate(ICommand command, Parameters args) {
        return command.validate(args);
    }
}
var logger =  CommandLogger();
var loggedCommand =  InterceptedCommand(logger, command);
// Each called command will output: Executed command <command name>
Implemented types

Constructors

InterceptedCommand(ICommandInterceptor interceptor, ICommand next)
Creates a new InterceptedCommand, which serves as a link in an execution chain. Contains information about the interceptor that is being used and the next command in the chain. [...]

Properties

hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

execute(String correlationId, Parameters args) → Future
Executes the next command in the execution chain using the given Parameters parameters (arguments). [...]
override
getName() → String
Returns the name of the command that is being intercepted.
override
validate(Parameters args) → List<ValidationResult>
Validates the Parameters parameters (arguments) that are to be passed to the command that is next in the execution chain. [...]
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator. [...]
inherited