Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.github.joschi.dropwizard.elasticsearch.util;
 
 
 import java.util.List;

Helper class for converting Guava com.google.common.net.HostAndPort objects to Elasticsearch org.elasticsearch.common.transport.TransportAddress.
public class TransportAddressHelper {
    private static final int DEFAULT_PORT = 9300;

    
    public static TransportAddress fromHostAndPort(final HostAndPort hostAndPort) {
        return new InetSocketTransportAddress(hostAndPort.getHostText(), hostAndPort.getPortOrDefault());
    }

    
    public static TransportAddress[] fromHostAndPorts(final List<HostAndPorthostAndPorts) {
        if (hostAndPorts == null) {
            return new TransportAddress[0];
        } else {
            TransportAddress[] transportAddresses = new TransportAddress[hostAndPorts.size()];
            for (int i = 0; i < hostAndPorts.size(); i++) {
                transportAddresses[i] = fromHostAndPort(hostAndPorts.get(i));
            }
            return transportAddresses;
        }
    }
New to GrepCode? Check out our FAQ X