From f23cd942f1456d766a7d8bfddd43a4488f97d2c6 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Tue, 30 May 2023 13:40:36 +1000 Subject: [PATCH] Use a static class --- .../NonApplicationRootPathBuildItem.java | 42 ++++++++++++++----- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/NonApplicationRootPathBuildItem.java b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/NonApplicationRootPathBuildItem.java index d34176ffd7bbc1..5c739cb0a2dd06 100644 --- a/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/NonApplicationRootPathBuildItem.java +++ b/extensions/vertx-http/deployment/src/main/java/io/quarkus/vertx/http/deployment/NonApplicationRootPathBuildItem.java @@ -4,6 +4,7 @@ import java.util.function.Consumer; import java.util.function.Function; +import io.quarkus.runtime.annotations.RecordableConstructor; import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.config.ConfigProvider; @@ -323,17 +324,7 @@ public RouteBuildItem.Builder orderedRoute(String route, Integer order) { @Override public RouteBuildItem.Builder orderedRoute(String route, Integer order, Consumer routeCustomizer) { - routeFunction(route, new Consumer() { - @Override - public void accept(Route route) { - if (order != null) { - route.order(order); - } - if (routeCustomizer != null) { - routeCustomizer.accept(route); - } - } - }); + routeFunction(route, new OrderFunction(order, routeCustomizer)); return this; } @@ -423,6 +414,35 @@ public Builder management() { super.management(); return this; } + + public static class OrderFunction implements Consumer { + final Integer order; + final Consumer routeCustomizer; + + @RecordableConstructor() + public OrderFunction(Integer order, Consumer routeCustomizer) { + this.order = order; + this.routeCustomizer = routeCustomizer; + } + + @Override + public void accept(Route route) { + if (order != null) { + route.order(order); + } + if (routeCustomizer != null) { + routeCustomizer.accept(route); + } + } + + public Integer getOrder() { + return order; + } + + public Consumer getRouteCustomizer() { + return routeCustomizer; + } + } } /**