@Test(expectedExceptions = IllegalArgumentException.class) public void testParseNoHost() { KafkaBrokerAddress.valueOf(":666"); }
public static KafkaBrokerAddress valueOf(String brokerAddress) throws IllegalArgumentException { if (brokerAddress == null) { badArg(null); } String str = brokerAddress.trim(); if (str.isEmpty()) { badArg(brokerAddress); } int lastColon = str.lastIndexOf(":"); if (lastColon == -1) { badArg(brokerAddress); } int portNumber = -1; try { portNumber = Integer.parseInt(str.substring(lastColon + 1).trim()); validatePortNumber(portNumber); } catch (NumberFormatException e) { badArg(brokerAddress); } String hostName = str.substring(0, lastColon); hostName = validateHostname(hostName); return new KafkaBrokerAddress(hostName, portNumber); }
KafkaBrokerAddress { public static KafkaBrokerAddress valueOf(String brokerAddress) throws IllegalArgumentException { if (brokerAddress == null) { badArg(null); } String str = brokerAddress.trim(); if (str.isEmpty()) { badArg(brokerAddress); } int lastColon = str.lastIndexOf(":"); if (lastColon == -1) { badArg(brokerAddress); } int portNumber = -1; try { portNumber = Integer.parseInt(str.substring(lastColon + 1).trim()); validatePortNumber(portNumber); } catch (NumberFormatException e) { badArg(brokerAddress); } String hostName = str.substring(0, lastColon); hostName = validateHostname(hostName); return new KafkaBrokerAddress(hostName, portNumber); } }
KafkaBrokerAddress { public static KafkaBrokerAddress valueOf(String brokerAddress) throws IllegalArgumentException { if (brokerAddress == null) { badArg(null); } String str = brokerAddress.trim(); if (str.isEmpty()) { badArg(brokerAddress); } int lastColon = str.lastIndexOf(":"); if (lastColon == -1) { badArg(brokerAddress); } int portNumber = -1; try { portNumber = Integer.parseInt(str.substring(lastColon + 1).trim()); validatePortNumber(portNumber); } catch (NumberFormatException e) { badArg(brokerAddress); } String hostName = str.substring(0, lastColon); hostName = validateHostname(hostName); return new KafkaBrokerAddress(hostName, portNumber); } KafkaBrokerAddress(String hostName, int portNumber); }
KafkaBrokerAddress { public static KafkaBrokerAddress valueOf(String brokerAddress) throws IllegalArgumentException { if (brokerAddress == null) { badArg(null); } String str = brokerAddress.trim(); if (str.isEmpty()) { badArg(brokerAddress); } int lastColon = str.lastIndexOf(":"); if (lastColon == -1) { badArg(brokerAddress); } int portNumber = -1; try { portNumber = Integer.parseInt(str.substring(lastColon + 1).trim()); validatePortNumber(portNumber); } catch (NumberFormatException e) { badArg(brokerAddress); } String hostName = str.substring(0, lastColon); hostName = validateHostname(hostName); return new KafkaBrokerAddress(hostName, portNumber); } KafkaBrokerAddress(String hostName, int portNumber); String getHostName(); int getPortNumber(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static KafkaBrokerAddress valueOf(String brokerAddress); }
KafkaBrokerAddress { public static KafkaBrokerAddress valueOf(String brokerAddress) throws IllegalArgumentException { if (brokerAddress == null) { badArg(null); } String str = brokerAddress.trim(); if (str.isEmpty()) { badArg(brokerAddress); } int lastColon = str.lastIndexOf(":"); if (lastColon == -1) { badArg(brokerAddress); } int portNumber = -1; try { portNumber = Integer.parseInt(str.substring(lastColon + 1).trim()); validatePortNumber(portNumber); } catch (NumberFormatException e) { badArg(brokerAddress); } String hostName = str.substring(0, lastColon); hostName = validateHostname(hostName); return new KafkaBrokerAddress(hostName, portNumber); } KafkaBrokerAddress(String hostName, int portNumber); String getHostName(); int getPortNumber(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static KafkaBrokerAddress valueOf(String brokerAddress); static final Comparator<KafkaBrokerAddress> BY_URL; }