Skip to content

Commit 5ff899a

Browse files
committed
router: clean up
- remove Route.Decorator
1 parent 71305e1 commit 5ff899a

5 files changed

Lines changed: 11 additions & 37 deletions

File tree

jooby/src/main/java/io/jooby/Body.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ default Iterator<Value> iterator() {
9191
long getSize();
9292

9393
/**
94-
* Body as readable channel.
94+
* Body as a readable channel.
9595
*
96-
* @return Body as readable channel.
96+
* @return Body as a readable channel.
9797
*/
9898
ReadableByteChannel channel();
9999

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ public String getContextPath() {
309309
* you don't configure the same service twice or more in the main and imported applications too.
310310
*
311311
* @param factory Application factory.
312-
* @return This application.
312+
* @return Created routes.
313313
*/
314-
@NonNull public Jooby install(@NonNull SneakyThrows.Supplier<Jooby> factory) {
314+
@NonNull public RouteSet install(@NonNull SneakyThrows.Supplier<Jooby> factory) {
315315
return install("/", factory);
316316
}
317317

@@ -343,13 +343,12 @@ public String getContextPath() {
343343
*
344344
* @param path Path prefix.
345345
* @param factory Application factory.
346-
* @return This application.
346+
* @return Created routes.
347347
*/
348-
@NonNull public Jooby install(@NonNull String path, @NonNull SneakyThrows.Supplier<Jooby> factory) {
348+
@NonNull public RouteSet install(@NonNull String path, @NonNull SneakyThrows.Supplier<Jooby> factory) {
349349
try {
350350
owner = this;
351-
path(path, factory::get);
352-
return this;
351+
return path(path, factory::get);
353352
} finally {
354353
owner = null;
355354
}

jooby/src/main/java/io/jooby/Route.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,6 @@ public void setRoute(Route route) {
106106
}
107107
}
108108

109-
/**
110-
* @deprecated use {@link Route.Filter}.
111-
*/
112-
@Deprecated
113-
public interface Decorator extends Filter {}
114-
115109
/**
116110
* Decorates a handler and run logic before handler is executed.
117111
*

jooby/src/main/java/io/jooby/RouteSet.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,9 @@
55
*/
66
package io.jooby;
77

8-
import static java.util.Collections.EMPTY_LIST;
98
import static java.util.Optional.ofNullable;
109

11-
import java.util.ArrayList;
12-
import java.util.Arrays;
13-
import java.util.Collection;
14-
import java.util.List;
15-
import java.util.Map;
10+
import java.util.*;
1611
import java.util.concurrent.Executor;
1712

1813
import edu.umd.cs.findbugs.annotations.NonNull;
@@ -29,7 +24,7 @@ public class RouteSet {
2924

3025
private List<Route> routes;
3126

32-
private List<String> tags = EMPTY_LIST;
27+
private List<String> tags;
3328

3429
private String summary;
3530

@@ -154,7 +149,7 @@ public class RouteSet {
154149
* @return Route tags.
155150
*/
156151
public @NonNull List<String> getTags() {
157-
return tags;
152+
return tags == null ? List.of() : tags;
158153
}
159154

160155
/**
@@ -164,9 +159,7 @@ public class RouteSet {
164159
* @return This route.
165160
*/
166161
public @NonNull RouteSet setTags(@NonNull List<String> tags) {
167-
if (this.tags == EMPTY_LIST) {
168-
this.tags = new ArrayList<>();
169-
}
162+
this.tags = tags;
170163
routes.forEach(it -> tags.forEach(it::addTag));
171164
return this;
172165
}

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -522,18 +522,6 @@ default Object execute(@NonNull Context context) {
522522
*/
523523
@NonNull Router use(@NonNull Route.Filter filter);
524524

525-
/**
526-
* Attach a filter to the route pipeline.
527-
*
528-
* @param filter Filter.
529-
* @return This router.
530-
* @deprecated Use {@link #use(Route.Filter)}.
531-
*/
532-
@Deprecated
533-
default @NonNull Router decorator(@NonNull Route.Decorator filter) {
534-
return use(filter);
535-
}
536-
537525
/**
538526
* Add a before route decorator to the route pipeline.
539527
*

0 commit comments

Comments
 (0)