@Test public void testFormatAddress() { assertEquals("127.0.0.1:8000", formatAddress("127.0.0.1", 8000)); assertEquals("mydomain.com:8080", formatAddress("mydomain.com", 8080)); assertEquals("[::1]:1234", formatAddress("::1", 1234)); assertEquals("[2001:db8:85a3:8d3:1319:8a2e:370:7348]:5678", formatAddress("2001:db8:85a3:8d3:1319:8a2e:370:7348", 5678)); }
public static String formatAddress(String host, Integer port) { return host.contains(":") ? "[" + host + "]:" + port : host + ":" + port; }
Utils { public static String formatAddress(String host, Integer port) { return host.contains(":") ? "[" + host + "]:" + port : host + ":" + port; } }
Utils { public static String formatAddress(String host, Integer port) { return host.contains(":") ? "[" + host + "]:" + port : host + ":" + port; }  }
Utils { public static String formatAddress(String host, Integer port) { return host.contains(":") ? "[" + host + "]:" + port : host + ":" + port; }  static List<T> sorted(Collection<T> collection); static String utf8(byte[] bytes); static String utf8(ByteBuffer buffer, int length); static String utf8(ByteBuffer buffer, int offset, int length); static byte[] utf8(String string); static int abs(int n); static long min(long first, long ... rest); static long max(long first, long ... rest); static short min(short first, short second); static int utf8Length(CharSequence s); static byte[] toArray(ByteBuffer buffer); static byte[] toArray(ByteBuffer buffer, int size); static byte[] toNullableArray(ByteBuffer buffer); static ByteBuffer wrapNullable(byte[] array); static byte[] toArray(ByteBuffer buffer, int offset, int size); static T notNull(T t); static void sleep(long ms); static T newInstance(Class<T> c); static T newInstance(String klass, Class<T> base); static int murmur2(final byte[] data); static String getHost(String address); static Integer getPort(String address); static String formatAddress(String host, Integer port); static String join(T[] strs, String separator); static String join(Collection<T> list, String separator); static String mkString(Map<K, V> map, String begin, String end,
                                         String keyValueSeparator, String elementSeparator); static Properties loadProps(String filename); static Map<String, String> propsToStringMap(Properties props); static String stackTrace(Throwable e); static Thread newThread(String name, Runnable runnable, boolean daemon); static Thread daemonThread(String name, Runnable runnable); static void croak(String message); static byte[] readBytes(ByteBuffer buffer, int offset, int length); static byte[] readBytes(ByteBuffer buffer); static String readFileAsString(String path, Charset charset); static String readFileAsString(String path); static ByteBuffer ensureCapacity(ByteBuffer existingBuffer, int newLength); @SafeVarargs static Set<T> mkSet(T... elems); @SafeVarargs static List<T> mkList(T... elems); static void delete(final File file); static List<T> safe(List<T> other); static ClassLoader getKafkaClassLoader(); static ClassLoader getContextOrKafkaClassLoader(); static void atomicMoveWithFallback(Path source, Path target); static void closeAll(Closeable... closeables); static void closeQuietly(AutoCloseable closeable, String name); static int toPositive(int number); static int longHashcode(long value); static ByteBuffer sizeDelimited(ByteBuffer buffer, int start); static void readFullyOrFail(FileChannel channel, ByteBuffer destinationBuffer, long position,
                                       String description); static void readFully(FileChannel channel, ByteBuffer destinationBuffer, long position); static final void readFully(InputStream inputStream, ByteBuffer destinationBuffer); static void writeFully(FileChannel channel, ByteBuffer sourceBuffer); static void writeTo(DataOutput out, ByteBuffer buffer, int length); static List<T> toList(Iterator<T> iterator); }
Utils { public static String formatAddress(String host, Integer port) { return host.contains(":") ? "[" + host + "]:" + port : host + ":" + port; }  static List<T> sorted(Collection<T> collection); static String utf8(byte[] bytes); static String utf8(ByteBuffer buffer, int length); static String utf8(ByteBuffer buffer, int offset, int length); static byte[] utf8(String string); static int abs(int n); static long min(long first, long ... rest); static long max(long first, long ... rest); static short min(short first, short second); static int utf8Length(CharSequence s); static byte[] toArray(ByteBuffer buffer); static byte[] toArray(ByteBuffer buffer, int size); static byte[] toNullableArray(ByteBuffer buffer); static ByteBuffer wrapNullable(byte[] array); static byte[] toArray(ByteBuffer buffer, int offset, int size); static T notNull(T t); static void sleep(long ms); static T newInstance(Class<T> c); static T newInstance(String klass, Class<T> base); static int murmur2(final byte[] data); static String getHost(String address); static Integer getPort(String address); static String formatAddress(String host, Integer port); static String join(T[] strs, String separator); static String join(Collection<T> list, String separator); static String mkString(Map<K, V> map, String begin, String end,
                                         String keyValueSeparator, String elementSeparator); static Properties loadProps(String filename); static Map<String, String> propsToStringMap(Properties props); static String stackTrace(Throwable e); static Thread newThread(String name, Runnable runnable, boolean daemon); static Thread daemonThread(String name, Runnable runnable); static void croak(String message); static byte[] readBytes(ByteBuffer buffer, int offset, int length); static byte[] readBytes(ByteBuffer buffer); static String readFileAsString(String path, Charset charset); static String readFileAsString(String path); static ByteBuffer ensureCapacity(ByteBuffer existingBuffer, int newLength); @SafeVarargs static Set<T> mkSet(T... elems); @SafeVarargs static List<T> mkList(T... elems); static void delete(final File file); static List<T> safe(List<T> other); static ClassLoader getKafkaClassLoader(); static ClassLoader getContextOrKafkaClassLoader(); static void atomicMoveWithFallback(Path source, Path target); static void closeAll(Closeable... closeables); static void closeQuietly(AutoCloseable closeable, String name); static int toPositive(int number); static int longHashcode(long value); static ByteBuffer sizeDelimited(ByteBuffer buffer, int start); static void readFullyOrFail(FileChannel channel, ByteBuffer destinationBuffer, long position,
                                       String description); static void readFully(FileChannel channel, ByteBuffer destinationBuffer, long position); static final void readFully(InputStream inputStream, ByteBuffer destinationBuffer); static void writeFully(FileChannel channel, ByteBuffer sourceBuffer); static void writeTo(DataOutput out, ByteBuffer buffer, int length); static List<T> toList(Iterator<T> iterator); static final String NL; }