private static <V> Router<V> router(boolean isTrie, List<V> values, @Nullable V fallbackValue,
                                        @Nullable BiFunction<Route, V, V> fallbackValueConfigurator,
                                        Function<V, Route> routeResolver, boolean isRouteDecorator) {
        final Comparator<V> valueComparator =
                Comparator.comparingInt(e -> -1 * routeResolver.apply(e).complexity());

        final Router<V> router;
        if (isTrie) {
            final RoutingTrieBuilder<V> builder = new RoutingTrieBuilder<>();
            // Set a comparator to sort services by the number of conditions to check in a descending order.
            builder.comparator(valueComparator);
            for (V v : values) {
                final Route route = routeResolver.apply(v);
                builder.add(route.paths().get(1), v);

                if (fallbackValue != null) {
                    // Add an extra route without a trailing slash for a redirect.
                    // Note that `path.length()` must be greater than 1 because path is `/` when 1.
                    final String path = route.paths().get(0);
                    final int pathLen = path.length();
                    if (pathLen > 1 && path.charAt(pathLen - 1) == '/') {
                        final V newFallbackValue =
                                fallbackValueConfigurator != null ?
                                fallbackValueConfigurator.apply(route, fallbackValue) : fallbackValue;
                        builder.add(path.substring(0, pathLen - 1),
                                    newFallbackValue, /* hasHighPrecedence */ false);
                    }
                }
            }
            router = new TrieRouter<>(builder.build(), routeResolver, isRouteDecorator);
        } else {
            values.sort(valueComparator);
            router = new SequentialRouter<>(values, routeResolver, isRouteDecorator);
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Router created for {} service(s): {}",
                         values.size(), router.getClass().getSimpleName());
            for (V v : values) {
                final Route route = routeResolver.apply(v);
                logger.debug("patternString: {}, complexity: {}", route.patternString(), route.complexity());
            }
        }
        values.clear();
        return router;
    }
Returns a {@link Router} implementation which is using one of {@link RoutingTrie} and {@link List}.
core/src/main/java/com/linecorp/armeria/server/Routers.java