1 package jalview.ws2.actions;
3 import java.util.EnumSet;
4 import java.util.Objects;
6 import jalview.ws2.actions.api.ActionI;
7 import jalview.ws2.api.CredentialType;
8 import jalview.ws2.api.WebService;
11 * An abstract base class storing common data and implementing their getters
12 * defined in {@link ActionI} interface. The concrete action implementations are
13 * encouraged to extend this class and provide their own {@code perform} and
14 * {@code isActive} implementations.
20 public abstract class BaseAction<R> implements ActionI<R>
22 public static abstract class Builder<A extends BaseAction<?>>
24 protected WebService<A> webService;
26 protected String name;
28 protected String tooltip = "";
30 protected String subcategory = null;
32 protected int minSequences = -1;
34 protected int maxSequences = -1;
36 protected boolean allowProtein = true;
38 protected boolean allowNucleotide = true;
40 protected EnumSet<CredentialType> requiredCredentials = EnumSet.noneOf(CredentialType.class);
42 public Builder(String name)
47 public void webService(WebService<A> val)
49 this.webService = val;
52 public void tooltip(String val)
57 public void subcategory(String val)
62 public void minSequences(int val)
67 public void maxSequecnes(int val)
72 public void allowProtein(boolean val)
77 public void allowNucleotide(boolean val)
79 allowNucleotide = val;
82 public void addRequiredCredential(CredentialType val)
84 requiredCredentials.add(val);
87 public void requiredCredentials(EnumSet<CredentialType> val)
89 requiredCredentials = val;
93 protected final WebService<? extends ActionI<R>> webService;
95 protected final String name;
97 protected final String tooltip;
99 protected final String subcategory;
101 protected final int minSequences;
103 protected final int maxSequences;
105 protected final boolean allowProtein;
107 protected final boolean allowNucleotide;
109 protected final EnumSet<CredentialType> requiredCredentials;
111 protected BaseAction(Builder<? extends BaseAction<R>> builder)
113 Objects.requireNonNull(builder.webService);
114 this.webService = builder.webService;
115 this.name = builder.name;
116 this.tooltip = builder.tooltip;
117 this.subcategory = builder.subcategory;
118 this.minSequences = builder.minSequences;
119 this.maxSequences = builder.maxSequences;
120 this.allowProtein = builder.allowProtein;
121 this.allowNucleotide = builder.allowNucleotide;
122 this.requiredCredentials = builder.requiredCredentials;
126 public WebService<? extends ActionI<R>> getWebService()
132 public String getName()
138 public String getTooltip()
144 public String getSubcategory()
150 public int getMinSequences()
156 public int getMaxSequences()
162 public boolean doAllowProtein()
168 public boolean doAllowNucleotide()
170 return allowNucleotide;
174 public EnumSet<CredentialType> getRequiredCredentials()
176 return requiredCredentials;