From: Mateusz Warowny Date: Wed, 10 May 2023 09:22:28 +0000 (+0200) Subject: JAL-3954 Implement NullAction and NullTask for testing purposes X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5cf81fe99aece38c571385e643b48fc861a9be77;p=jalview.git JAL-3954 Implement NullAction and NullTask for testing purposes --- 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