1 package jalview.ws2.actions;
3 import java.util.EnumSet;
5 import jalview.ws2.actions.api.ActionI;
6 import jalview.ws2.api.CredentialType;
9 * An abstract base class storing common data and implementing their getters
10 * defined in {@link ActionI} interface. The concrete action implementations are
11 * encouraged to extend this class and provide their own {@code perform} and
12 * {@code isActive} implementations.
19 public abstract class BaseAction<T> implements ActionI<T>
21 public static class Builder
23 protected String name;
25 protected String tooltip = "";
27 protected String subcategory = null;
29 protected int minSequences = -1;
31 protected int maxSequences = -1;
33 protected boolean allowProtein = true;
35 protected boolean allowNucleotide = true;
37 protected EnumSet<CredentialType> requiredCredentials = EnumSet.noneOf(CredentialType.class);
39 public Builder(String name)
44 public void tooltip(String val)
49 public void subcategory(String val)
54 public void minSequences(int val)
59 public void maxSequecnes(int val)
64 public void allowProtein(boolean val)
69 public void allowNucleotide(boolean val)
71 allowNucleotide = val;
74 public void addRequiredCredential(CredentialType val)
76 requiredCredentials.add(val);
79 public void requiredCredentials(EnumSet<CredentialType> val)
81 requiredCredentials = val;
85 protected final String name;
87 protected final String tooltip;
89 protected final String subcategory;
91 protected final int minSequences;
93 protected final int maxSequences;
95 protected final boolean allowProtein;
97 protected final boolean allowNucleotide;
99 protected final EnumSet<CredentialType> requiredCredentials;
101 protected BaseAction(Builder builder)
103 this.name = builder.name;
104 this.tooltip = builder.tooltip;
105 this.subcategory = builder.subcategory;
106 this.minSequences = builder.minSequences;
107 this.maxSequences = builder.maxSequences;
108 this.allowProtein = builder.allowProtein;
109 this.allowNucleotide = builder.allowNucleotide;
110 this.requiredCredentials = builder.requiredCredentials;
113 public static Builder newBuilder(String name)
115 return new Builder(name);
119 public String getName()
125 public String getTooltip()
131 public String getSubcategory()
137 public int getMinSequences()
143 public int getMaxSequences()
149 public boolean doAllowProtein()
155 public boolean doAllowNucleotide()
157 return allowNucleotide;
161 public EnumSet<CredentialType> getRequiredCredentials()
163 return requiredCredentials;