class InetAddressUtils {

    public static InetAddress getAddressForBan(@CheckForNull String hostname) throws InvalidInetAddressException {
        if (hostname == null) {
            throw new InvalidInetAddressException("null address", null);
        }

        String name = hostname.trim();
        if (name.length() == 0) {
            throw new InvalidInetAddressException("empty address", null);
        }

        //TODO(mmarquez): should we validate address format ??
        try {
            InetAddress address = InetAddress.getByName(name);

            if (address.isLoopbackAddress() || address.isAnyLocalAddress()) {
                throw new InvalidInetAddressException("local address: '" + name + "'", null);
            }

            return address;
        }
        catch (UnknownHostException ex) {
            throw new InvalidInetAddressException("unknown host: '" + name + "'", ex);
        }
    }

    private  InetAddressUtils();

}