code: private static <V> Router<V> router(boolean isTrie, List<V> values,
                                          Function<V, PathMapping> pathMappingResolver) {
          final Comparator<V> valueComparator =
                  Comparator.comparingInt(e -> -1 * pathMappingResolver.apply(e).complexity());
  
          final Router<V> router;
          if (isTrie) {
              final RoutingTrie.Builder<V> builder = new Builder<>();
              // Set a comparator to sort services by the number of conditions to be checked in a descending
              // order.
              builder.comparator(valueComparator);
              values.forEach(v -> builder.add(pathMappingResolver.apply(v).triePath().get(), v));
              router = new TrieRouter<>(builder.build(), pathMappingResolver);
          } else {
              values.sort(valueComparator);
              router = new SequentialRouter<>(values, pathMappingResolver);
          }
  
          if (logger.isDebugEnabled()) {
              logger.debug("Router created for {} service(s): {}",
                           values.size(), router.getClass().getSimpleName());
              values.forEach(c -> {
                  final PathMapping mapping = pathMappingResolver.apply(c);
                  logger.debug("meterTag: {}, complexity: {}", mapping.meterTag(), mapping.complexity());
              });
          }
          values.clear();
          return router;
      }
docs: Returns a {@link Router} implementation which is using one of {@link RoutingTrie} and {@link List}.