private static Int2ObjectMap<Mapping<String, VirtualHost>> buildDomainAndPortMapping(
            VirtualHost defaultVirtualHost, List<VirtualHost> virtualHosts) {

        final List<VirtualHost> portMappingVhosts = virtualHosts.stream()
                                                                .filter(v -> v.port() > 0)
                                                                .collect(toImmutableList());
        final Map<Integer, VirtualHost> portMappingDefaultVhosts =
                portMappingVhosts.stream()
                                 .filter(v -> v.hostnamePattern().startsWith("*:"))
                                 .collect(toImmutableMap(VirtualHost::port, Function.identity()));

        final Map<Integer, DomainMappingBuilder<VirtualHost>> mappingsBuilder = new HashMap<>();
        for (VirtualHost virtualHost : portMappingVhosts) {
            final int port = virtualHost.port();
            // The default virtual host should be either '*' or '*:<port>'.
            final VirtualHost defaultVhost =
                    firstNonNull(portMappingDefaultVhosts.get(port), defaultVirtualHost);
            // Builds a 'DomainMappingBuilder' with 'defaultVhost' for the port if absent.
            final DomainMappingBuilder<VirtualHost> mappingBuilder =
                    mappingsBuilder.computeIfAbsent(port, key -> new DomainMappingBuilder<>(defaultVhost));

            if (defaultVhost == virtualHost) {
                // The 'virtualHost' was added already as a default value when creating 'DomainMappingBuilder'.
            } else {
                mappingBuilder.add(virtualHost.hostnamePattern(), virtualHost);
            }
        }

        final Int2ObjectMap<Mapping<String, VirtualHost>> mappings =
                new Int2ObjectOpenHashMap<>(mappingsBuilder.size() + 1);

        mappingsBuilder.forEach((port, builder) -> mappings.put(port.intValue(), builder.build()));
        // Add name-based virtual host mappings.
        mappings.put(-1, buildDomainMapping(defaultVirtualHost, virtualHosts));
        return mappings;
    }
Initialized later by {@link Server} via {@link #setServer(Server)}.
core/src/main/java/com/linecorp/armeria/server/DefaultServerConfig.java