public static void configurePorts(ServerBuilder server, List<Port> ports) {
        requireNonNull(server, "server");
        requireNonNull(ports, "ports");
        ports.forEach(p -> {
            final String ip = p.getIp();
            final String iface = p.getIface();
            final int port = p.getPort();
            final List<SessionProtocol> protocols = p.getProtocols();

            if (ip == null) {
                if (iface == null) {
                    server.port(new ServerPort(port, protocols));
                } else {
                    try {
                        final Enumeration<InetAddress> e = NetworkInterface.getByName(iface).getInetAddresses();
                        while (e.hasMoreElements()) {
                            server.port(new ServerPort(new InetSocketAddress(e.nextElement(), port),
                                                       protocols));
                        }
                    } catch (SocketException e) {
                        throw new IllegalStateException("Failed to find an iface: " + iface, e);
                    }
                }
            } else if (iface == null) {
                if (NetUtil.isValidIpV4Address(ip) || NetUtil.isValidIpV6Address(ip)) {
                    final byte[] bytes = NetUtil.createByteArrayFromIpAddressString(ip);
                    try {
                        server.port(new ServerPort(new InetSocketAddress(
                                InetAddress.getByAddress(bytes), port), protocols));
                    } catch (UnknownHostException e) {
                        // Should never happen.
                        throw new Error(e);
                    }
                } else {
                    throw new IllegalStateException("invalid IP address: " + ip);
                }
            } else {
                throw new IllegalStateException("A port cannot have both IP and iface: " + p);
            }
        });
    }
public static void configurePorts ( ServerBuilder server , List < Port > ports ) { requireNonNull ( server , "server" ) ; requireNonNull ( ports , "ports" ) ; ports . forEach ( p -> { final String ip = p . getIp ( ) ; final String iface = p . getIface ( ) ; final int port = p . getPort ( ) ; final List < SessionProtocol > protocols = p . getProtocols ( ) ; if ( ip == null ) { if ( iface == null ) { server . port ( new ServerPort ( port , protocols ) ) ; } else { try { final Enumeration < InetAddress > e = NetworkInterface . getByName ( iface ) . getInetAddresses ( ) ; while ( e . hasMoreElements ( ) ) { server . port ( new ServerPort ( new InetSocketAddress ( e . nextElement ( ) , port ) , protocols ) ) ; } } catch ( SocketException e ) { throw new IllegalStateException ( "Failed to find an iface: " + iface , e ) ; } } } else if ( iface == null ) { if ( NetUtil . isValidIpV4Address ( ip ) || NetUtil . isValidIpV6Address ( ip ) ) { final byte [ ] bytes = NetUtil . createByteArrayFromIpAddressString ( ip ) ; try { server . port ( new ServerPort ( new InetSocketAddress ( InetAddress . getByAddress ( bytes ) , port ) , protocols ) ) ; } catch ( UnknownHostException e ) { throw new Error ( e ) ; } } else { throw new IllegalStateException ( "invalid IP address: " + ip ) ; } } else { throw new IllegalStateException ( "A port cannot have both IP and iface: " + p ) ; } } ) ; }
Adds {@link Port}s to the specified {@link ServerBuilder}.