private static List<ServerPort> resolveDistinctPorts(List<ServerPort> ports) {
        final List<ServerPort> distinctPorts = new ArrayList<>();
        for (final ServerPort port : ports) {
            boolean found = false;
            // Do not check the port number 0 because a user may want his or her server to be bound
            // on multiple arbitrary ports.
            final InetSocketAddress portAddress = port.localAddress();
            if (portAddress.getPort() > 0) {
                for (int i = 0; i < distinctPorts.size(); i++) {
                    final ServerPort distinctPort = distinctPorts.get(i);
                    final InetSocketAddress distinctPortAddress = distinctPort.localAddress();

                    // Compare the addresses taking `DomainSocketAddress` into account.
                    final boolean hasSameAddress;
                    if (portAddress instanceof DomainSocketAddress) {
                        if (distinctPortAddress instanceof DomainSocketAddress) {
                            hasSameAddress = ((DomainSocketAddress) portAddress).path().equals(
                                    ((DomainSocketAddress) distinctPortAddress).path());
                        } else {
                            hasSameAddress = false;
                        }
                    } else {
                        hasSameAddress = portAddress.equals(distinctPortAddress);
                    }

                    // Merge two `ServerPort`s into one if their addresses are equal.
                    if (hasSameAddress) {
                        final ServerPort merged =
                                new ServerPort(distinctPort.localAddress(),
                                               Sets.union(distinctPort.protocols(), port.protocols()));
                        distinctPorts.set(i, merged);
                        found = true;
                        break;
                    }
                }
            }

            if (!found) {
                distinctPorts.add(port);
            }
        }
        return Collections.unmodifiableList(distinctPorts);
    }
Returns a list of {@link ServerPort}s which consists of distinct port numbers except for the port
{@code 0}. If there are the same port numbers with different {@link SessionProtocol}s,
their {@link SessionProtocol}s will be merged into a single {@link ServerPort} instance.
The returned list is sorted as the same order of the specified {@code ports}.
core/src/main/java/com/linecorp/armeria/server/ServerBuilder.java