From 5cf81fe99aece38c571385e643b48fc861a9be77 Mon Sep 17 00:00:00 2001 From: Mateusz Warowny Date: Wed, 10 May 2023 11:22:28 +0200 Subject: [PATCH] JAL-3954 Implement NullAction and NullTask for testing purposes --- src/jalview/ws2/actions/NullAction.java | 52 +++++++++++++++++++++++++++++++ src/jalview/ws2/actions/NullTask.java | 47 ++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 src/jalview/ws2/actions/NullAction.java create mode 100644 src/jalview/ws2/actions/NullTask.java diff --git a/src/jalview/ws2/actions/NullAction.java b/src/jalview/ws2/actions/NullAction.java new file mode 100644 index 0000000..655a133 --- /dev/null +++ b/src/jalview/ws2/actions/NullAction.java @@ -0,0 +1,52 @@ +package jalview.ws2.actions; + +import java.util.List; + +import jalview.viewmodel.AlignmentViewport; +import jalview.ws.params.ArgumentI; +import jalview.ws2.actions.api.ActionI; +import jalview.ws2.actions.api.TaskEventListener; +import jalview.ws2.actions.api.TaskI; +import jalview.ws2.api.Credentials; + +/** + * An empty implementation of the {@link ActionI} interface that does nothing. + * Use as a placeholder for testing purposes. + * + * @author mmwarowny + * + */ +public final class NullAction extends BaseAction +{ + public static final class Builder extends BaseAction.Builder + { + public NullAction build() + { + return new NullAction(this); + } + } + + public static Builder newBuilder() + { + return new Builder(); + } + + protected NullAction(Builder builder) + { + super(builder); + } + + @Override + public TaskI perform(AlignmentViewport viewport, + List args, Credentials credentials, + TaskEventListener handler) + { + return new NullTask(); + } + + @Override + public boolean isActive(AlignmentViewport viewport) + { + return false; + } +} diff --git a/src/jalview/ws2/actions/NullTask.java b/src/jalview/ws2/actions/NullTask.java new file mode 100644 index 0000000..223b9fb --- /dev/null +++ b/src/jalview/ws2/actions/NullTask.java @@ -0,0 +1,47 @@ +package jalview.ws2.actions; + +import java.util.Collections; +import java.util.List; + +import jalview.ws2.actions.api.JobI; +import jalview.ws2.actions.api.TaskI; +import jalview.ws2.api.JobStatus; + +/** + * An empty task returned by the {@link NullAction}. Use as a placeholder + * for testing purposes. + * + * @author mmwarowny + * + */ +class NullTask implements TaskI +{ + @Override + public long getUid() + { + return 0; + } + + @Override + public JobStatus getStatus() + { + return JobStatus.READY; + } + + @Override + public List getSubJobs() + { + return Collections.emptyList(); + } + + @Override + public Void getResult() + { + return null; + } + + @Override + public void cancel() + { + } +} \ No newline at end of file -- 1.7.10.2