1 package jalview.ws2.api;
4 import java.util.ArrayList;
5 import java.util.Collections;
7 import jalview.ws.params.ParamDatastoreI;
8 import jalview.ws2.actions.Action;
10 import static java.util.Objects.requireNonNull;
12 public class WebService<T extends Action>
14 public static class Builder<T extends Action>
18 private String clientName;
20 private String category;
24 private String description = "";
26 private ParamDatastoreI paramDatastore;
28 private List<T> actions = new ArrayList<>();
30 private Class<T> actionClass;
32 public Builder<T> url(URL val)
38 public Builder<T> clientName(String val)
44 public Builder<T> category(String val)
50 public Builder<T> name(String val)
56 public Builder<T> description(String val)
62 public Builder<T> paramDatastore(ParamDatastoreI val)
68 public Builder<T> actions(List<T> val)
74 public Builder<T> action(T val)
80 public Builder<T> actionClass(Class<T> val)
86 public WebService<T> build()
89 requireNonNull(clientName);
90 requireNonNull(category);
92 requireNonNull(paramDatastore);
93 requireNonNull(actions);
94 if (actions.size() == 0)
95 throw new IllegalArgumentException("Empty actions list");
96 requireNonNull(actionClass);
97 return new WebService<T>(this);
101 private final URL url;
103 private final String clientName;
105 private final String category;
107 private final String name;
109 private final String description;
111 private final ParamDatastoreI paramDatastore;
113 private final List<T> actions;
115 private final Class<T> actionClass;
117 WebService(Builder<T> builder)
119 this.url = builder.url;
120 this.clientName = builder.clientName;
121 this.category = builder.category;
122 this.name = builder.name;
123 this.description = builder.description;
124 this.paramDatastore = builder.paramDatastore;
125 this.actions = Collections.unmodifiableList(builder.actions);
126 this.actionClass = builder.actionClass;
129 public static <T extends Action> Builder<T> newBuilder()
131 return new Builder<T>();
139 String getClientName()
154 String getDescription()
159 ParamDatastoreI getParamDatastore()
161 return paramDatastore;
169 Class<T> getActionClass()