Skip to content

Commit 33cc4e4

Browse files
committed
Small spellfixes and refactoring
1 parent 0d12b34 commit 33cc4e4

18 files changed

+130
-137
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,4 @@ hs_err_pid*
2525

2626
*.idea
2727
*.iml
28-
29-
test/
30-
_psd
28+
/_psd

src/examples/Examples.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static void main(String[] args) throws IOException {
8282

8383
app.get("/session", (req, res) -> {
8484

85-
/**
85+
/*
8686
* CookieSession named his data "Session Cookie" which is
8787
* an SessionCookie so we can Cast it.
8888
*/

src/examples/PortMiddleware.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void handle(Request req, Response res) {
2323
// Add the port to the request middleware map
2424
req.addMiddlewareContent(this, port);
2525

26-
/**
26+
/*
2727
* After that you can use this middleware by call:
2828
* app.use(new PortMiddleware());
2929
*

src/express/Express.java

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package express;
22

3-
import com.sun.istack.internal.NotNull;
43
import com.sun.net.httpserver.HttpServer;
54
import com.sun.net.httpserver.HttpsConfigurator;
65
import com.sun.net.httpserver.HttpsServer;
@@ -52,7 +51,7 @@ public class Express implements Router {
5251
*
5352
* @param hostname The host name
5453
*/
55-
public Express(@NotNull String hostname) {
54+
public Express(String hostname) {
5655
this.hostname = hostname;
5756
}
5857

@@ -61,7 +60,7 @@ public Express(@NotNull String hostname) {
6160
*
6261
* @param httpsConfigurator The HttpsConfigurator for https
6362
*/
64-
public Express(@NotNull HttpsConfigurator httpsConfigurator) {
63+
public Express(HttpsConfigurator httpsConfigurator) {
6564
this.httpsConfigurator = httpsConfigurator;
6665
}
6766

@@ -72,7 +71,7 @@ public Express(@NotNull HttpsConfigurator httpsConfigurator) {
7271
* @param hostname The host name
7372
* @param httpsConfigurator The HttpsConfigurator for https
7473
*/
75-
public Express(@NotNull String hostname, HttpsConfigurator httpsConfigurator) {
74+
public Express(String hostname, HttpsConfigurator httpsConfigurator) {
7675
this.hostname = hostname;
7776
this.httpsConfigurator = httpsConfigurator;
7877
}
@@ -96,7 +95,7 @@ public boolean isSecure() {
9695
* @param param The parameter name.
9796
* @param request An request handler.
9897
*/
99-
public void onParam(@NotNull String param, @NotNull HttpRequest request) {
98+
public void onParam(String param, HttpRequest request) {
10099
PARAMETER_LISTENER.put(param, request);
101100
}
102101

@@ -133,7 +132,7 @@ public Object get(String key) {
133132
* @param executor The new executor.
134133
* @throws IOException If the server is currently running
135134
*/
136-
public void setExecutor(@NotNull Executor executor) throws IOException {
135+
public void setExecutor(Executor executor) throws IOException {
137136
if (httpServer != null) {
138137
throw new IOException("Cannot set the executor after the server has starderd!");
139138
} else {
@@ -146,7 +145,7 @@ public void setExecutor(@NotNull Executor executor) throws IOException {
146145
*
147146
* @param router The router.
148147
*/
149-
public void use(@NotNull ExpressRouter router) {
148+
public void use(ExpressRouter router) {
150149
this.HANDLER.combine(router.getHandler());
151150
this.WORKER.addAll(router.getWorker());
152151
}
@@ -158,7 +157,7 @@ public void use(@NotNull ExpressRouter router) {
158157
* @param router The router.
159158
*/
160159
@SuppressWarnings("unchecked")
161-
public void use(@NotNull String root, @NotNull ExpressRouter router) {
160+
public void use(String root, ExpressRouter router) {
162161

163162
router.getHandler().forEach(fl -> fl.getFilter().forEach(layer -> {
164163
((FilterImpl) layer).setRoot(root);
@@ -168,100 +167,95 @@ public void use(@NotNull String root, @NotNull ExpressRouter router) {
168167
this.WORKER.addAll(router.getWorker());
169168
}
170169

171-
public void use(@NotNull HttpRequest middleware) {
170+
public void use(HttpRequest middleware) {
172171
addMiddleware("*", "*", middleware);
173172
}
174173

175-
public void use(@NotNull String context, @NotNull HttpRequest middleware) {
174+
public void use(String context, HttpRequest middleware) {
176175
addMiddleware("*", context, middleware);
177176
}
178177

179-
public void use(@NotNull String context, @NotNull String requestMethod, @NotNull HttpRequest middleware) {
178+
public void use(String context, String requestMethod, HttpRequest middleware) {
180179
addMiddleware(requestMethod.toUpperCase(), context, middleware);
181180
}
182181

183182
// Internal service to handle middleware
184-
private void addMiddleware(@NotNull String requestMethod, @NotNull String context, HttpRequest middleware) {
183+
private void addMiddleware(String requestMethod, String context, HttpRequest middleware) {
185184
if (middleware instanceof FilterTask) {
186185
WORKER.add(new FilterWorker((FilterTask) middleware));
187186
}
188187

189188
HANDLER.add(0, new FilterImpl(requestMethod, context, middleware));
190189
}
191190

192-
public void all(@NotNull HttpRequest request) {
191+
public void all(HttpRequest request) {
193192
HANDLER.add(1, new FilterImpl("*", "*", request));
194193
}
195194

196-
public void all(@NotNull String context, @NotNull HttpRequest request) {
195+
public void all(String context, HttpRequest request) {
197196
HANDLER.add(1, new FilterImpl("*", context, request));
198197
}
199198

200-
public void all(@NotNull String context, @NotNull String requestMethod, @NotNull HttpRequest request) {
199+
public void all(String context, String requestMethod, HttpRequest request) {
201200
HANDLER.add(1, new FilterImpl(requestMethod, context, request));
202201
}
203202

204-
public void get(@NotNull String context, @NotNull HttpRequest request) {
203+
public void get(String context, HttpRequest request) {
205204
HANDLER.add(1, new FilterImpl("GET", context, request));
206205
}
207206

208-
public void post(@NotNull String context, @NotNull HttpRequest request) {
207+
public void post(String context, HttpRequest request) {
209208
HANDLER.add(1, new FilterImpl("POST", context, request));
210209
}
211210

212-
public void put(@NotNull String context, @NotNull HttpRequest request) {
211+
public void put(String context, HttpRequest request) {
213212
HANDLER.add(1, new FilterImpl("PUT", context, request));
214213
}
215214

216-
public void delete(@NotNull String context, @NotNull HttpRequest request) {
215+
public void delete(String context, HttpRequest request) {
217216
HANDLER.add(1, new FilterImpl("DELETE", context, request));
218217
}
219218

220-
public void patch(@NotNull String context, @NotNull HttpRequest request) {
219+
public void patch(String context, HttpRequest request) {
221220
HANDLER.add(1, new FilterImpl("PATCH", context, request));
222221
}
223222

224223
/**
225224
* Start the HTTP-Server on port 80.
226-
* This method is asyncronous so be sure to add an listener or keep it in mind!
227-
*
228-
* @throws IOException - If an IO-Error occurs, eg. the port is already in use.
225+
* This method is asynchronous so be sure to add an listener or keep it in mind!
229226
*/
230-
public void listen() throws IOException {
227+
public void listen() {
231228
listen(null, 80);
232229
}
233230

234231
/**
235232
* Start the HTTP-Server on a specific port
236-
* This method is asyncronous so be sure to add an listener or keep it in mind!
233+
* This method is asynchronous so be sure to add an listener or keep it in mind!
237234
*
238235
* @param port The port.
239-
* @throws IOException - If an IO-Error occurs, eg. the port is already in use.
240236
*/
241-
public void listen(int port) throws IOException {
237+
public void listen(int port) {
242238
listen(null, port);
243239
}
244240

245241
/**
246242
* Start the HTTP-Server on port 80.
247-
* This method is asyncronous so be sure to add an listener or keep it in mind!
243+
* This method is asynchronous so be sure to add an listener or keep it in mind!
248244
*
249245
* @param onStart An listener which will be fired after the server is stardet.
250-
* @throws IOException - If an IO-Error occurs, eg. the port is already in use.
251246
*/
252-
public void listen(ExpressListener onStart) throws IOException {
247+
public void listen(ExpressListener onStart) {
253248
listen(onStart, 80);
254249
}
255250

256251
/**
257252
* Start the HTTP-Server on a specific port.
258-
* This method is asyncronous so be sure to add an listener or keep it in mind!
253+
* This method is asynchronous so be sure to add an listener or keep it in mind!
259254
*
260255
* @param onStart An listener which will be fired after the server is stardet.
261256
* @param port The port.
262-
* @throws IOException - If an IO-Error occurs, eg. the port is already in use.
263257
*/
264-
public void listen(ExpressListener onStart, int port) throws IOException {
258+
public void listen(ExpressListener onStart, int port) {
265259
new Thread(() -> {
266260
try {
267261
// Fire worker threads

src/express/ExpressRouter.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package express;
22

3-
import com.sun.istack.internal.NotNull;
43
import express.filter.FilterImpl;
54
import express.filter.FilterLayerHandler;
65
import express.filter.FilterTask;
@@ -24,55 +23,55 @@ public class ExpressRouter implements Router {
2423
HANDLER = new FilterLayerHandler(2);
2524
}
2625

27-
public void use(@NotNull HttpRequest middleware) {
26+
public void use(HttpRequest middleware) {
2827
addMiddleware("*", "*", middleware);
2928
}
3029

31-
public void use(@NotNull String context, @NotNull HttpRequest middleware) {
30+
public void use(String context, HttpRequest middleware) {
3231
addMiddleware("*", context, middleware);
3332
}
3433

35-
public void use(@NotNull String context, @NotNull String requestMethod, @NotNull HttpRequest middleware) {
34+
public void use(String context, String requestMethod, HttpRequest middleware) {
3635
addMiddleware(requestMethod.toUpperCase(), context, middleware);
3736
}
3837

39-
private void addMiddleware(@NotNull String requestMethod, @NotNull String context, HttpRequest middleware) {
38+
private void addMiddleware(String requestMethod, String context, HttpRequest middleware) {
4039
if (middleware instanceof FilterTask) {
4140
WORKER.add(new FilterWorker((FilterTask) middleware));
4241
}
4342

4443
HANDLER.add(0, new FilterImpl(requestMethod, context, middleware));
4544
}
4645

47-
public void all(@NotNull HttpRequest request) {
46+
public void all(HttpRequest request) {
4847
HANDLER.add(1, new FilterImpl("*", "*", request));
4948
}
5049

51-
public void all(@NotNull String context, @NotNull HttpRequest request) {
50+
public void all(String context, HttpRequest request) {
5251
HANDLER.add(1, new FilterImpl("*", context, request));
5352
}
5453

55-
public void all(@NotNull String context, @NotNull String requestMethod, @NotNull HttpRequest request) {
54+
public void all(String context, String requestMethod, HttpRequest request) {
5655
HANDLER.add(1, new FilterImpl(requestMethod, context, request));
5756
}
5857

59-
public void get(@NotNull String context, @NotNull HttpRequest request) {
58+
public void get(String context, HttpRequest request) {
6059
HANDLER.add(1, new FilterImpl("GET", context, request));
6160
}
6261

63-
public void post(@NotNull String context, @NotNull HttpRequest request) {
62+
public void post(String context, HttpRequest request) {
6463
HANDLER.add(1, new FilterImpl("POST", context, request));
6564
}
6665

67-
public void put(@NotNull String context, @NotNull HttpRequest request) {
66+
public void put(String context, HttpRequest request) {
6867
HANDLER.add(1, new FilterImpl("PUT", context, request));
6968
}
7069

71-
public void delete(@NotNull String context, @NotNull HttpRequest request) {
70+
public void delete(String context, HttpRequest request) {
7271
HANDLER.add(1, new FilterImpl("DELETE", context, request));
7372
}
7473

75-
public void patch(@NotNull String context, @NotNull HttpRequest request) {
74+
public void patch(String context, HttpRequest request) {
7675
HANDLER.add(1, new FilterImpl("PATCH", context, request));
7776
}
7877

0 commit comments

Comments
 (0)