ConfigConverters { public static ConfigConverter<InetSocketAddress> ofInetSocketAddress() { return new SimpleConfigConverter<InetSocketAddress>() { @Override public InetSocketAddress fromString(String addressPort) { try { return parseInetSocketAddress(addressPort); } catch (ParseException e) { throw new IllegalArgumentException(e); } } @Override public String toString(InetSocketAddress value) { return value.getAddress().getHostAddress() + ":" + value.getPort(); } }; }  static ConfigConverter<LocalDate> ofLocalDate(); static ConfigConverter<LocalTime> ofLocalTime(); static ConfigConverter<LocalDateTime> ofLocalDateTime(); static ConfigConverter<Period> ofPeriod(); static ConfigConverter<Integer> ofPeriodAsDays(); static ConfigConverter<Duration> ofDuration(); static ConfigConverter<Long> ofDurationAsMillis(); static ConfigConverter<Instant> ofInstant(); static ConfigConverter<Long> ofInstantAsEpochMillis(); static ConfigConverter<String> ofString(); static ConfigConverter<String> ofNullableString(); static ConfigConverter<Byte> ofByte(); static ConfigConverter<Integer> ofInteger(); static ConfigConverter<Long> ofLong(); static ConfigConverter<Float> ofFloat(); static ConfigConverter<Double> ofDouble(); static ConfigConverter<Boolean> ofBoolean(); static SimpleConfigConverter<E> ofEnum(Class<E> enumClass); static ConfigConverter<Class<?>> ofClass(); static ConfigConverter<InetAddress> ofInetAddress(); static ConfigConverter<InetSocketAddress> ofInetSocketAddress(); static ConfigConverter<Path> ofPath(); static ConfigConverter<MemSize> ofMemSize(); static ConfigConverter<Long> ofMemSizeAsLong(); static ConfigConverter<Integer> ofMemSizeAsInt(); static ConfigConverter<List<T>> ofList(ConfigConverter<T> elementConverter, CharSequence separators); static ConfigConverter<List<T>> ofList(ConfigConverter<T> elementConverter); static ConfigConverter<ServerSocketSettings> ofServerSocketSettings(); static ConfigConverter<SocketSettings> ofSocketSettings(); static ConfigConverter<DatagramSocketSettings> ofDatagramSocketSettings(); static ConfigConverter<FatalErrorHandler> ofFatalErrorHandler(); static ConfigConverter<Schedule> ofEventloopTaskSchedule(); static ConfigConverter<RetryPolicy> ofRetryPolicy(); static ConfigConverter<ThrottlingController> ofThrottlingController(); static ConfigConverter<SimpleThreadFactory> ofThreadFactory(); static ExecutorService getExecutor(Config config); static ConfigConverter<ExecutorService> ofExecutor(); static UnaryOperator<T> apply(BiFunction<T, ? super V, T> modifier, V value); static UnaryOperator<T> applyIf(BiFunction<T, ? super V, T> modifier, V value, Predicate<? super V> predicate); static UnaryOperator<T> applyIfNotNull(BiFunction<T, ? super V, T> modifier, V value); static final ConfigConverter<List<Class<?>>> OF_CLASSES; }
@Test public void testInetAddressConverter() throws UnknownHostException { ConfigConverter<InetSocketAddress> inetSocketAddressConverter = ConfigConverters.ofInetSocketAddress(); Map<String, Config> map = new HashMap<>(); map.put("key1", Config.ofValue("192.168.1.1:80")); map.put("key2", Config.ofValue("250.200.100.50:10000")); map.put("key3", Config.ofValue("1.0.0.0:65000")); Config root = Config.ofConfigs(map); InetSocketAddress address1 = new InetSocketAddress(InetAddress.getByName("192.168.1.1"), 80); InetSocketAddress address2 = new InetSocketAddress(InetAddress.getByName("250.200.100.50"), 10000); InetSocketAddress address3 = new InetSocketAddress(InetAddress.getByName("1.0.0.0"), 65000); assertEquals(address1, inetSocketAddressConverter.get(root.getChild("key1"))); assertEquals(address2, inetSocketAddressConverter.get(root.getChild("key2"))); assertEquals(address3, inetSocketAddressConverter.get(root.getChild("key3"))); }