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.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
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
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
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
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited