Skip to content

Commit ba297bf

Browse files
committed
Add Nonnull annotations
1 parent 04ed99f commit ba297bf

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

jooby/src/main/java/io/jooby/Jooby.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ public Jooby() {
8383

8484
}
8585

86-
public Env environment() {
86+
public @Nonnull Env environment() {
8787
return environment;
8888
}
8989

90-
public Jooby environment(@Nonnull Env environment) {
90+
public @Nonnull Jooby environment(@Nonnull Env environment) {
9191
this.environment = environment;
9292
if (tmpdir == null) {
9393
tmpdir = Paths.get(environment.get("application.tmpdir").value()).toAbsolutePath();
@@ -105,23 +105,23 @@ public Jooby environment(@Nonnull Env environment) {
105105
return this;
106106
}
107107

108-
public Jooby onStart(@Nonnull Throwing.Runnable task) {
108+
public @Nonnull Jooby onStart(@Nonnull Throwing.Runnable task) {
109109
if (startCallbacks == null) {
110110
startCallbacks = new ArrayList<>();
111111
}
112112
startCallbacks.add(task);
113113
return this;
114114
}
115115

116-
public Jooby onStarted(@Nonnull Throwing.Runnable task) {
116+
public @Nonnull Jooby onStarted(@Nonnull Throwing.Runnable task) {
117117
if (readyCallbacks == null) {
118118
readyCallbacks = new ArrayList<>();
119119
}
120120
readyCallbacks.add(task);
121121
return this;
122122
}
123123

124-
public Jooby onStop(@Nonnull Throwing.Runnable task) {
124+
public @Nonnull Jooby onStop(@Nonnull Throwing.Runnable task) {
125125
if (stopCallbacks == null) {
126126
stopCallbacks = new LinkedList<>();
127127
}
@@ -246,7 +246,7 @@ public Jooby errorCode(@Nonnull Class<? extends Throwable> type,
246246
return router.worker();
247247
}
248248

249-
@Nonnull @Override public Jooby worker(Executor worker) {
249+
@Nonnull @Override public Jooby worker(@Nonnull Executor worker) {
250250
this.router.worker(worker);
251251
if (worker instanceof ExecutorService) {
252252
onStop(((ExecutorService) worker)::shutdown);
@@ -260,64 +260,64 @@ public Jooby errorCode(@Nonnull Class<? extends Throwable> type,
260260
}
261261

262262
/** Log: */
263-
public Logger log() {
263+
public @Nonnull Logger log() {
264264
return LoggerFactory.getLogger(getClass());
265265
}
266266

267267
@Nonnull @Override public ErrorHandler errorHandler() {
268268
return router.errorHandler();
269269
}
270270

271-
public Path tmpdir() {
271+
public @Nonnull Path tmpdir() {
272272
return tmpdir;
273273
}
274274

275-
public Jooby tmpdir(@Nonnull Path tmpdir) {
275+
public @Nonnull Jooby tmpdir(@Nonnull Path tmpdir) {
276276
this.tmpdir = tmpdir;
277277
return this;
278278
}
279279

280-
public ExecutionMode mode() {
281-
return mode;
280+
public @Nonnull ExecutionMode mode() {
281+
return mode == null ? ExecutionMode.DEFAULT : mode;
282282
}
283283

284-
public Jooby mode(ExecutionMode mode) {
284+
public @Nonnull Jooby mode(@Nonnull ExecutionMode mode) {
285285
this.mode = mode;
286286
return this;
287287
}
288288

289-
public <T> T require(Class<T> type) {
289+
public @Nonnull <T> T require(@Nonnull Class<T> type) {
290290
return findService(type, type.getName());
291291
}
292292

293-
public <T> T require(Class<T> type, String name) {
293+
public @Nonnull <T> T require(@Nonnull Class<T> type, @Nonnull String name) {
294294
return findService(type, type.getName() + "." + name);
295295
}
296296

297-
private <T> T findService(Class<T> type, String key) {
297+
private @Nonnull <T> T findService(@Nonnull Class<T> type, @Nonnull String key) {
298298
Object service = services.get(key);
299299
if (service == null) {
300300
throw new IllegalStateException("Service not found: " + type);
301301
}
302302
return type.cast(service);
303303
}
304304

305-
public <T> Jooby addService(@Nonnull Class<T> type, @Nonnull T service) {
305+
public @Nonnull <T> Jooby addService(@Nonnull Class<T> type, @Nonnull T service) {
306306
putService(type, null, service);
307307
return this;
308308
}
309309

310-
public <T> Jooby addService(@Nonnull T service) {
310+
public @Nonnull <T> Jooby addService(@Nonnull T service) {
311311
putService(service.getClass(), null, service);
312312
return this;
313313
}
314314

315-
public <T> Jooby addService(@Nonnull String name, @Nonnull T service) {
315+
public @Nonnull <T> Jooby addService(@Nonnull String name, @Nonnull T service) {
316316
putService(service.getClass(), name, service);
317317
return this;
318318
}
319319

320-
public <T> Jooby addService(@Nonnull Class<T> type, @Nonnull String name, @Nonnull T service) {
320+
public @Nonnull <T> Jooby addService(@Nonnull Class<T> type, @Nonnull String name, @Nonnull T service) {
321321
putService(type, name, service);
322322
return this;
323323
}
@@ -333,7 +333,7 @@ private void putService(@Nonnull Class type, String name, @Nonnull Object servic
333333
}
334334

335335
/** Boot: */
336-
public Server start() {
336+
public @Nonnull Server start() {
337337
List<Server> servers = stream(
338338
spliteratorUnknownSize(
339339
ServiceLoader.load(Server.class).iterator(),
@@ -356,7 +356,7 @@ public Server start() {
356356
return server.start(this);
357357
}
358358

359-
public Jooby start(Server server) {
359+
public @Nonnull Jooby start(@Nonnull Server server) {
360360
/** Start router: */
361361
ensureTmpdir(tmpdir);
362362
Logger log = log();
@@ -372,7 +372,7 @@ public Jooby start(Server server) {
372372
return this;
373373
}
374374

375-
public Jooby ready(Server server) {
375+
public @Nonnull Jooby ready(@Nonnull Server server) {
376376
Logger log = log();
377377

378378
fireStarted();
@@ -393,7 +393,7 @@ public Jooby ready(Server server) {
393393
return this;
394394
}
395395

396-
public Jooby stop() {
396+
public @Nonnull Jooby stop() {
397397
if (router != null) {
398398
router.destroy();
399399
router = null;
@@ -403,7 +403,7 @@ public Jooby stop() {
403403
return this;
404404
}
405405

406-
public Jooby configureServer(Consumer<Server> configurer) {
406+
public @Nonnull Jooby configureServer(@Nonnull Consumer<Server> configurer) {
407407
this.serverConfigurer = configurer;
408408
return this;
409409
}
@@ -412,15 +412,15 @@ public Jooby configureServer(Consumer<Server> configurer) {
412412
return router.toString();
413413
}
414414

415-
public static void setEnv(Env environment) {
415+
public static void setEnv(@Nonnull Env environment) {
416416
ENV.set(environment);
417417
}
418418

419-
public static void run(Supplier<Jooby> provider, String... args) {
419+
public static void run(@Nonnull Supplier<Jooby> provider, String... args) {
420420
run(provider, ExecutionMode.DEFAULT, args);
421421
}
422422

423-
public static void run(Supplier<Jooby> provider, ExecutionMode mode, String... args) {
423+
public static void run(@Nonnull Supplier<Jooby> provider, @Nonnull ExecutionMode mode, String... args) {
424424
Server server;
425425
try {
426426
Env environment = Env.defaultEnvironment(args);
@@ -440,7 +440,7 @@ public static void run(Supplier<Jooby> provider, ExecutionMode mode, String... a
440440
server.join();
441441
}
442442

443-
public static void logback(Env env) {
443+
public static void logback(@Nonnull Env env) {
444444
String setfile = env.get("logback.configurationFile").value((String) null);
445445
if (setfile != null) {
446446
System.setProperty("logback.configurationFile", setfile);

jooby/src/main/java/io/jooby/Router.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ public interface Router {
3535
interface Match {
3636
boolean matches();
3737

38-
Route route();
38+
@Nonnull Route route();
3939

40-
void execute(Context context);
40+
void execute(@Nonnull Context context);
4141

42-
Map<String, String> pathMap();
42+
@Nonnull Map<String, String> pathMap();
4343
}
4444

4545
/** HTTP Methods: */
@@ -203,9 +203,9 @@ default Router error(@Nonnull Predicate<StatusCode> predicate,
203203

204204
@Nonnull ErrorHandler errorHandler();
205205

206-
Logger log();
206+
@Nonnull Logger log();
207207

208-
static String normalizePath(@Nonnull String path, boolean caseSensitive,
208+
static @Nonnull String normalizePath(@Nonnull String path, boolean caseSensitive,
209209
boolean ignoreTrailingSlash) {
210210
if (path == null || path.length() == 0 || path.equals("/")) {
211211
return "/";
@@ -247,7 +247,7 @@ static String normalizePath(@Nonnull String path, boolean caseSensitive,
247247
return path;
248248
}
249249

250-
static List<String> pathKeys(String pattern) {
250+
static @Nonnull List<String> pathKeys(@Nonnull String pattern) {
251251
List<String> result = new ArrayList<>();
252252
int start = -1;
253253
int end = Integer.MAX_VALUE;

0 commit comments

Comments
 (0)