Example usage for com.google.common.net HostAndPort requireBracketsForIPv6

List of usage examples for com.google.common.net HostAndPort requireBracketsForIPv6

Introduction

In this page you can find the example usage for com.google.common.net HostAndPort requireBracketsForIPv6.

Prototype

public HostAndPort requireBracketsForIPv6() 

Source Link

Document

Generate an error if the host might be a non-bracketed IPv6 literal.

Usage

From source file:com.github.jcustenborder.kafka.connect.utils.config.validators.ValidHostAndPort.java

void validate(final String setting, final String input) {
    HostAndPort hostAndPort = HostAndPort.fromString(input);
    if (this.requireBracketsForIPv6) {
        hostAndPort = hostAndPort.requireBracketsForIPv6();
    }/*from w w w.  ja va  2s  .  c  o  m*/
    if (null != this.defaultPort) {
        hostAndPort.withDefaultPort(this.defaultPort);
    }

    if (Strings.isNullOrEmpty(hostAndPort.getHostText())) {
        throw new ConfigException(String.format("'%s'(%s) host cannot be blank or null.", setting, input));
    }

    if (this.portRequired && !hostAndPort.hasPort()) {
        throw new ConfigException(String.format("'%s'(%s) must specify a port.", setting, input));
    }

}