Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 16:11:35 GMT
  2. Package jalview.ws2.actions

File BaseAction.java

 

Coverage histogram

../../../img/srcFileCovDistChart8.png
20% of files have more coverage

Code metrics

2
32
22
2
203
145
24
0.75
1.45
11
1.09

Classes

Class Line # Actions
BaseAction 27 22 13
0.771428677.1%
BaseAction.Builder 29 10 11
0.6190476461.9%
 

Contributing tests

This file is covered by 484 tests. .

Source view

1    package jalview.ws2.actions;
2   
3    import java.util.EnumSet;
4    import java.util.List;
5    import java.util.Objects;
6   
7    import jalview.gui.AlignViewport;
8    import jalview.viewmodel.AlignmentViewport;
9    import jalview.ws.params.ArgumentI;
10    import jalview.ws2.actions.api.ActionI;
11    import jalview.ws2.actions.api.TaskEventListener;
12    import jalview.ws2.actions.api.TaskI;
13    import jalview.ws2.api.CredentialType;
14    import jalview.ws2.api.Credentials;
15    import jalview.ws2.api.WebService;
16   
17    /**
18    * An abstract base class storing common data and implementing their getters
19    * defined in {@link ActionI} interface. The concrete action implementations are
20    * encouraged to extend this class and provide their own {@code perform} and
21    * {@code isActive} implementations.
22    *
23    * @author mmwarowny
24    * @param <R>
25    * task result type
26    */
 
27    public abstract class BaseAction<R> implements ActionI<R>
28    {
 
29    public static abstract class Builder<A extends BaseAction<?>>
30    {
31    protected WebService<A> webService;
32   
33    protected String name = null;
34   
35    protected String tooltip = "";
36   
37    protected String subcategory = null;
38   
39    protected int minSequences = -1;
40   
41    protected int maxSequences = -1;
42   
43    protected boolean allowProtein = true;
44   
45    protected boolean allowNucleotide = true;
46   
47    protected EnumSet<CredentialType> requiredCredentials = EnumSet.noneOf(CredentialType.class);
48   
 
49  1740 toggle public Builder()
50    {
51    }
52   
 
53  1967 toggle public void name(String val)
54    {
55  1967 this.name = val;
56    }
57   
 
58  1740 toggle public void webService(WebService<A> val)
59    {
60  1740 this.webService = val;
61    }
62   
 
63  0 toggle public void tooltip(String val)
64    {
65  0 tooltip = val;
66    }
67   
 
68  454 toggle public void subcategory(String val)
69    {
70  454 subcategory = val;
71    }
72   
 
73  941 toggle public void minSequences(int val)
74    {
75  941 minSequences = val;
76    }
77   
 
78  0 toggle public void maxSequecnes(int val)
79    {
80  0 maxSequences = val;
81    }
82   
 
83  124 toggle public void allowProtein(boolean val)
84    {
85  124 allowProtein = val;
86    }
87   
 
88  124 toggle public void allowNucleotide(boolean val)
89    {
90  124 allowNucleotide = val;
91    }
92   
 
93  0 toggle public void addRequiredCredential(CredentialType val)
94    {
95  0 requiredCredentials.add(val);
96    }
97   
 
98  0 toggle public void requiredCredentials(EnumSet<CredentialType> val)
99    {
100  0 requiredCredentials = val;
101    }
102    }
103   
104    protected final WebService<? extends ActionI<R>> webService;
105   
106    protected final String name;
107   
108    protected final String tooltip;
109   
110    protected final String subcategory;
111   
112    protected final int minSequences;
113   
114    protected final int maxSequences;
115   
116    protected final boolean allowProtein;
117   
118    protected final boolean allowNucleotide;
119   
120    protected final EnumSet<CredentialType> requiredCredentials;
121   
 
122  1967 toggle protected BaseAction(Builder<? extends BaseAction<R>> builder)
123    {
124  1967 Objects.requireNonNull(builder.webService);
125  1967 this.webService = builder.webService;
126  1967 this.name = builder.name;
127  1967 this.tooltip = builder.tooltip;
128  1967 this.subcategory = builder.subcategory;
129  1967 this.minSequences = builder.minSequences;
130  1967 this.maxSequences = builder.maxSequences;
131  1967 this.allowProtein = builder.allowProtein;
132  1967 this.allowNucleotide = builder.allowNucleotide;
133  1967 this.requiredCredentials = builder.requiredCredentials;
134    }
135   
 
136  81134 toggle @Override
137    public WebService<? extends ActionI<R>> getWebService()
138    {
139  81134 return webService;
140    }
141   
 
142  250288 toggle @Override
143    public String getName()
144    {
145  250289 return name;
146    }
147   
148    /**
149    * Returns a full name of the action which comprises of the service name and
150    * the action name if present.
151    *
152    * @return full name of this action
153    */
 
154  7784 toggle public String getFullName()
155    {
156  7784 if (name == null || name.isEmpty())
157  3892 return webService.getName();
158    else
159  3892 return webService.getName() + " " + name;
160    }
161   
 
162  0 toggle @Override
163    public String getTooltip()
164    {
165  0 return tooltip;
166    }
167   
 
168  104491 toggle @Override
169    public String getSubcategory()
170    {
171  104491 return subcategory;
172    }
173   
 
174  0 toggle @Override
175    public int getMinSequences()
176    {
177  0 return minSequences;
178    }
179   
 
180  0 toggle @Override
181    public int getMaxSequences()
182    {
183  0 return maxSequences;
184    }
185   
 
186  77740 toggle @Override
187    public boolean doAllowProtein()
188    {
189  77740 return allowProtein;
190    }
191   
 
192  6438 toggle @Override
193    public boolean doAllowNucleotide()
194    {
195  6438 return allowNucleotide;
196    }
197   
 
198  0 toggle @Override
199    public EnumSet<CredentialType> getRequiredCredentials()
200    {
201  0 return requiredCredentials;
202    }
203    }