Skip to content

Commit

Permalink
Routes can be created from anything that is both Routable and an Http…
Browse files Browse the repository at this point in the history
…Handler
  • Loading branch information
shs96c committed Jul 4, 2019
1 parent e5ed023 commit bf74b7d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions java/client/src/org/openqa/selenium/remote/http/Route.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ public static NestedRouteConfig prefix(String prefix) {
return new NestedRouteConfig(prefix);
}

public static Route combine(Route first, Route... others) {
public static <T extends Routable & HttpHandler> Route combine(T first, T... others) {
Objects.requireNonNull(first, "At least one route must be set.");
return new CombinedRoute(Stream.concat(Stream.of(first), Stream.of(others)));
}

public static Route combine(Iterable<Route> routes) {
public static <T extends Routable & HttpHandler> Route combine(Iterable<T> routes) {
Objects.requireNonNull(routes, "At least one route must be set.");

return new CombinedRoute(StreamSupport.stream(routes.spliterator(), false));
Expand Down Expand Up @@ -271,11 +271,11 @@ private HttpRequest transform(HttpRequest request) {
}
}

private static class CombinedRoute extends Route {
private static class CombinedRoute<T extends Routable & HttpHandler> extends Route {

private final List<Route> allRoutes;
private final List<T> allRoutes;

public CombinedRoute(Stream<Route> routes) {
public CombinedRoute(Stream<T> routes) {
// We want later routes to have a greater chance of being called so that we can override
// routes as necessary.
allRoutes = routes.collect(ImmutableList.toImmutableList()).reverse();
Expand Down

0 comments on commit bf74b7d

Please sign in to comment.