This repository has been archived on 2021-12-05. You can view files and clone it, but cannot push or open issues or pull requests.
envoy/client/src/main/java/envoy/client/data/commands/InterruptingSystemCommand.java

53 lines
1.5 KiB
Java

package envoy.client.data.commands;
import java.util.function.Function;
import java.util.function.Supplier;
import envoy.client.event.InterruptEvent;
import envoy.event.EventBus;
/**
* This is a Envoy-specific subclass that allows
*
* Project: <strong>envoy-client</strong><br>
* File: <strong>InterruptingSystemCommand.java</strong><br>
* Created: <strong>23.07.2020</strong><br>
*
* @author Leon Hofmeister
* @since Envoy Client v0.2-beta
*/
public class InterruptingSystemCommand extends SystemCommand {
private static final EventBus eventBus = EventBus.getInstance();
/**
* The reason why an {@link InterruptEvent} will be dispatched from this class.
*/
public static final String interruptionReason = "command executed";
/**
* Constructs a new {@code SystemCommand}.
*
* @param action the action that should be performed
* @param numberOfArguments the amount of arguments that need to be parsed for
* the underlying function
* @param description the description of this {@code SystemCommand}
* @since Envoy Client v0.2-beta
*/
public InterruptingSystemCommand(Function<String[], Void> action, int numberOfArguments, String description) {
super(action, numberOfArguments, description);
}
@Override
public void onCall() {
super.onCall();
eventBus.dispatch(new InterruptEvent(interruptionReason));
}
@Override
public void onCall(Supplier<Void> consumer) {
super.onCall(consumer);
eventBus.dispatch(new InterruptEvent(interruptionReason));
}
}