Skip to content

Commit

Permalink
Use a static class
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed May 30, 2023
1 parent 571d584 commit f23cd94
Showing 1 changed file with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -323,17 +324,7 @@ public RouteBuildItem.Builder orderedRoute(String route, Integer order) {

@Override
public RouteBuildItem.Builder orderedRoute(String route, Integer order, Consumer<Route> routeCustomizer) {
routeFunction(route, new Consumer<Route>() {
@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;
}

Expand Down Expand Up @@ -423,6 +414,35 @@ public Builder management() {
super.management();
return this;
}

public static class OrderFunction implements Consumer<Route> {
final Integer order;
final Consumer<Route> routeCustomizer;

@RecordableConstructor()
public OrderFunction(Integer order, Consumer<Route> 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<Route> getRouteCustomizer() {
return routeCustomizer;
}
}
}

/**
Expand Down

0 comments on commit f23cd94

Please sign in to comment.