JAL-1601 Implement JPred4 client and discoverer
[jalview.git] / src / jalview / ws2 / helpers / WSClientTaskWrapper.java
1 package jalview.ws2.helpers;
2
3 import jalview.gui.WebserviceInfo;
4 import jalview.ws.WSClientI;
5 import jalview.ws2.actions.api.TaskI;
6
7 /**
8  * A simple wrapper around the {@link TaskI} implementing {@link WSClientI}. Its
9  * main purpose is to delegate the call to {@link #cancelJob} to the underlying
10  * task.
11  * 
12  * @author mmwarowny
13  */
14 public class WSClientTaskWrapper implements WSClientI
15 {
16   private TaskI<?> delegate;
17
18   private boolean cancellable;
19
20   private boolean canMerge;
21
22   public WSClientTaskWrapper(TaskI<?> task, boolean cancellable, boolean canMerge)
23   {
24     this.delegate = task;
25     this.cancellable = cancellable;
26     this.canMerge = canMerge;
27   }
28
29   public WSClientTaskWrapper(TaskI<?> task)
30   {
31     this(task, true, false);
32   }
33
34   @Override
35   public boolean isCancellable()
36   {
37     return cancellable;
38   }
39
40   @Override
41   public boolean canMergeResults()
42   {
43     return canMerge;
44   }
45
46   @Override
47   public void cancelJob()
48   {
49     delegate.cancel();
50   }
51
52 }