@Test public void testToInetAddress_OK() throws Exception { assertEquals(InetAddress.getByName("192.168.0.1"), StringHelper.toInetAddress("192.168.0.1").get()); assertEquals(InetAddress.getByName("0.0.0.0"), StringHelper.toInetAddress("0.0.0.0").get()); }
public static Optional<InetAddress> toInetAddress(String ip) { ip = StringUtils.trimToNull(ip); if (ip == null) { return Optional.empty(); } InetAddress addr = null; try { addr = InetAddress.getByName(ip); } catch (UnknownHostException | SecurityException e) { LOG.warn("Cannot convert: " + ip + " to valid IP: " + e.getMessage()); LOG.debug(e.getMessage(), e); } return Optional.ofNullable(addr); }
StringHelper { public static Optional<InetAddress> toInetAddress(String ip) { ip = StringUtils.trimToNull(ip); if (ip == null) { return Optional.empty(); } InetAddress addr = null; try { addr = InetAddress.getByName(ip); } catch (UnknownHostException | SecurityException e) { LOG.warn("Cannot convert: " + ip + " to valid IP: " + e.getMessage()); LOG.debug(e.getMessage(), e); } return Optional.ofNullable(addr); } }
StringHelper { public static Optional<InetAddress> toInetAddress(String ip) { ip = StringUtils.trimToNull(ip); if (ip == null) { return Optional.empty(); } InetAddress addr = null; try { addr = InetAddress.getByName(ip); } catch (UnknownHostException | SecurityException e) { LOG.warn("Cannot convert: " + ip + " to valid IP: " + e.getMessage()); LOG.debug(e.getMessage(), e); } return Optional.ofNullable(addr); }  }
StringHelper { public static Optional<InetAddress> toInetAddress(String ip) { ip = StringUtils.trimToNull(ip); if (ip == null) { return Optional.empty(); } InetAddress addr = null; try { addr = InetAddress.getByName(ip); } catch (UnknownHostException | SecurityException e) { LOG.warn("Cannot convert: " + ip + " to valid IP: " + e.getMessage()); LOG.debug(e.getMessage(), e); } return Optional.ofNullable(addr); }  static String decorate(String toDecorate, StringDecorator decorator, String... keywordsLc); static Optional<InetAddress> toInetAddress(String ip); }
StringHelper { public static Optional<InetAddress> toInetAddress(String ip) { ip = StringUtils.trimToNull(ip); if (ip == null) { return Optional.empty(); } InetAddress addr = null; try { addr = InetAddress.getByName(ip); } catch (UnknownHostException | SecurityException e) { LOG.warn("Cannot convert: " + ip + " to valid IP: " + e.getMessage()); LOG.debug(e.getMessage(), e); } return Optional.ofNullable(addr); }  static String decorate(String toDecorate, StringDecorator decorator, String... keywordsLc); static Optional<InetAddress> toInetAddress(String ip);  }