@Test public void testSocketSettings() { SocketSettings expected = SocketSettings.create() .withTcpNoDelay(true) .withReuseAddress(false) .withReceiveBufferSize(MemSize.of(256)) .withSendBufferSize(MemSize.of(512)) .withKeepAlive(true); SocketSettings actual = Config.EMPTY.get(ofSocketSettings(), THIS, expected); assertFalse(actual.hasReadBufferSize()); assertEquals(expected.getTcpNoDelay(), actual.getTcpNoDelay()); assertEquals(expected.getReuseAddress(), actual.getReuseAddress()); assertEquals(expected.getReceiveBufferSize(), actual.getReceiveBufferSize()); assertEquals(expected.getSendBufferSize(), actual.getSendBufferSize()); assertEquals(expected.getKeepAlive(), actual.getKeepAlive()); }
public static ConfigConverter<SocketSettings> ofSocketSettings() { return new ComplexConfigConverter<SocketSettings>(SocketSettings.create()) { @Override protected SocketSettings provide(Config config, SocketSettings defaultValue) { return Function.<SocketSettings>identity() .andThen(applyIfNotNull( SocketSettings::withReceiveBufferSize, config.get(ofMemSize(), "receiveBufferSize", defaultValue.hasReceiveBufferSize() ? defaultValue.getReceiveBufferSize() : null))) .andThen(applyIfNotNull( SocketSettings::withSendBufferSize, config.get(ofMemSize(), "sendBufferSize", defaultValue.hasSendBufferSize() ? defaultValue.getSendBufferSize() : null))) .andThen(applyIfNotNull( SocketSettings::withReuseAddress, config.get(ofBoolean(), "reuseAddress", defaultValue.hasReuseAddress() ? defaultValue.getReuseAddress() : null))) .andThen(applyIfNotNull( SocketSettings::withKeepAlive, config.get(ofBoolean(), "keepAlive", defaultValue.hasKeepAlive() ? defaultValue.getKeepAlive() : null))) .andThen(applyIfNotNull( SocketSettings::withTcpNoDelay, config.get(ofBoolean(), "tcpNoDelay", defaultValue.hasTcpNoDelay() ? defaultValue.getTcpNoDelay() : null))) .andThen(applyIfNotNull( SocketSettings::withImplReadTimeout, config.get(ofDuration(), "implReadTimeout", defaultValue.hasImplReadTimeout() ? defaultValue.getImplReadTimeout() : null))) .andThen(applyIfNotNull( SocketSettings::withImplWriteTimeout, config.get(ofDuration(), "implWriteTimeout", defaultValue.hasImplWriteTimeout() ? defaultValue.getImplWriteTimeout() : null))) .andThen(applyIfNotNull( SocketSettings::withImplReadBufferSize, config.get(ofMemSize(), "implReadBufferSize", defaultValue.hasReadBufferSize() ? defaultValue.getImplReadBufferSize() : null))) .apply(SocketSettings.create()); } }; }
ConfigConverters { public static ConfigConverter<SocketSettings> ofSocketSettings() { return new ComplexConfigConverter<SocketSettings>(SocketSettings.create()) { @Override protected SocketSettings provide(Config config, SocketSettings defaultValue) { return Function.<SocketSettings>identity() .andThen(applyIfNotNull( SocketSettings::withReceiveBufferSize, config.get(ofMemSize(), "receiveBufferSize", defaultValue.hasReceiveBufferSize() ? defaultValue.getReceiveBufferSize() : null))) .andThen(applyIfNotNull( SocketSettings::withSendBufferSize, config.get(ofMemSize(), "sendBufferSize", defaultValue.hasSendBufferSize() ? defaultValue.getSendBufferSize() : null))) .andThen(applyIfNotNull( SocketSettings::withReuseAddress, config.get(ofBoolean(), "reuseAddress", defaultValue.hasReuseAddress() ? defaultValue.getReuseAddress() : null))) .andThen(applyIfNotNull( SocketSettings::withKeepAlive, config.get(ofBoolean(), "keepAlive", defaultValue.hasKeepAlive() ? defaultValue.getKeepAlive() : null))) .andThen(applyIfNotNull( SocketSettings::withTcpNoDelay, config.get(ofBoolean(), "tcpNoDelay", defaultValue.hasTcpNoDelay() ? defaultValue.getTcpNoDelay() : null))) .andThen(applyIfNotNull( SocketSettings::withImplReadTimeout, config.get(ofDuration(), "implReadTimeout", defaultValue.hasImplReadTimeout() ? defaultValue.getImplReadTimeout() : null))) .andThen(applyIfNotNull( SocketSettings::withImplWriteTimeout, config.get(ofDuration(), "implWriteTimeout", defaultValue.hasImplWriteTimeout() ? defaultValue.getImplWriteTimeout() : null))) .andThen(applyIfNotNull( SocketSettings::withImplReadBufferSize, config.get(ofMemSize(), "implReadBufferSize", defaultValue.hasReadBufferSize() ? defaultValue.getImplReadBufferSize() : null))) .apply(SocketSettings.create()); } }; } }
ConfigConverters { public static ConfigConverter<SocketSettings> ofSocketSettings() { return new ComplexConfigConverter<SocketSettings>(SocketSettings.create()) { @Override protected SocketSettings provide(Config config, SocketSettings defaultValue) { return Function.<SocketSettings>identity() .andThen(applyIfNotNull( SocketSettings::withReceiveBufferSize, config.get(ofMemSize(), "receiveBufferSize", defaultValue.hasReceiveBufferSize() ? defaultValue.getReceiveBufferSize() : null))) .andThen(applyIfNotNull( SocketSettings::withSendBufferSize, config.get(ofMemSize(), "sendBufferSize", defaultValue.hasSendBufferSize() ? defaultValue.getSendBufferSize() : null))) .andThen(applyIfNotNull( SocketSettings::withReuseAddress, config.get(ofBoolean(), "reuseAddress", defaultValue.hasReuseAddress() ? defaultValue.getReuseAddress() : null))) .andThen(applyIfNotNull( SocketSettings::withKeepAlive, config.get(ofBoolean(), "keepAlive", defaultValue.hasKeepAlive() ? defaultValue.getKeepAlive() : null))) .andThen(applyIfNotNull( SocketSettings::withTcpNoDelay, config.get(ofBoolean(), "tcpNoDelay", defaultValue.hasTcpNoDelay() ? defaultValue.getTcpNoDelay() : null))) .andThen(applyIfNotNull( SocketSettings::withImplReadTimeout, config.get(ofDuration(), "implReadTimeout", defaultValue.hasImplReadTimeout() ? defaultValue.getImplReadTimeout() : null))) .andThen(applyIfNotNull( SocketSettings::withImplWriteTimeout, config.get(ofDuration(), "implWriteTimeout", defaultValue.hasImplWriteTimeout() ? defaultValue.getImplWriteTimeout() : null))) .andThen(applyIfNotNull( SocketSettings::withImplReadBufferSize, config.get(ofMemSize(), "implReadBufferSize", defaultValue.hasReadBufferSize() ? defaultValue.getImplReadBufferSize() : null))) .apply(SocketSettings.create()); } }; }  }
ConfigConverters { public static ConfigConverter<SocketSettings> ofSocketSettings() { return new ComplexConfigConverter<SocketSettings>(SocketSettings.create()) { @Override protected SocketSettings provide(Config config, SocketSettings defaultValue) { return Function.<SocketSettings>identity() .andThen(applyIfNotNull( SocketSettings::withReceiveBufferSize, config.get(ofMemSize(), "receiveBufferSize", defaultValue.hasReceiveBufferSize() ? defaultValue.getReceiveBufferSize() : null))) .andThen(applyIfNotNull( SocketSettings::withSendBufferSize, config.get(ofMemSize(), "sendBufferSize", defaultValue.hasSendBufferSize() ? defaultValue.getSendBufferSize() : null))) .andThen(applyIfNotNull( SocketSettings::withReuseAddress, config.get(ofBoolean(), "reuseAddress", defaultValue.hasReuseAddress() ? defaultValue.getReuseAddress() : null))) .andThen(applyIfNotNull( SocketSettings::withKeepAlive, config.get(ofBoolean(), "keepAlive", defaultValue.hasKeepAlive() ? defaultValue.getKeepAlive() : null))) .andThen(applyIfNotNull( SocketSettings::withTcpNoDelay, config.get(ofBoolean(), "tcpNoDelay", defaultValue.hasTcpNoDelay() ? defaultValue.getTcpNoDelay() : null))) .andThen(applyIfNotNull( SocketSettings::withImplReadTimeout, config.get(ofDuration(), "implReadTimeout", defaultValue.hasImplReadTimeout() ? defaultValue.getImplReadTimeout() : null))) .andThen(applyIfNotNull( SocketSettings::withImplWriteTimeout, config.get(ofDuration(), "implWriteTimeout", defaultValue.hasImplWriteTimeout() ? defaultValue.getImplWriteTimeout() : null))) .andThen(applyIfNotNull( SocketSettings::withImplReadBufferSize, config.get(ofMemSize(), "implReadBufferSize", defaultValue.hasReadBufferSize() ? defaultValue.getImplReadBufferSize() : null))) .apply(SocketSettings.create()); } }; }  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); }
ConfigConverters { public static ConfigConverter<SocketSettings> ofSocketSettings() { return new ComplexConfigConverter<SocketSettings>(SocketSettings.create()) { @Override protected SocketSettings provide(Config config, SocketSettings defaultValue) { return Function.<SocketSettings>identity() .andThen(applyIfNotNull( SocketSettings::withReceiveBufferSize, config.get(ofMemSize(), "receiveBufferSize", defaultValue.hasReceiveBufferSize() ? defaultValue.getReceiveBufferSize() : null))) .andThen(applyIfNotNull( SocketSettings::withSendBufferSize, config.get(ofMemSize(), "sendBufferSize", defaultValue.hasSendBufferSize() ? defaultValue.getSendBufferSize() : null))) .andThen(applyIfNotNull( SocketSettings::withReuseAddress, config.get(ofBoolean(), "reuseAddress", defaultValue.hasReuseAddress() ? defaultValue.getReuseAddress() : null))) .andThen(applyIfNotNull( SocketSettings::withKeepAlive, config.get(ofBoolean(), "keepAlive", defaultValue.hasKeepAlive() ? defaultValue.getKeepAlive() : null))) .andThen(applyIfNotNull( SocketSettings::withTcpNoDelay, config.get(ofBoolean(), "tcpNoDelay", defaultValue.hasTcpNoDelay() ? defaultValue.getTcpNoDelay() : null))) .andThen(applyIfNotNull( SocketSettings::withImplReadTimeout, config.get(ofDuration(), "implReadTimeout", defaultValue.hasImplReadTimeout() ? defaultValue.getImplReadTimeout() : null))) .andThen(applyIfNotNull( SocketSettings::withImplWriteTimeout, config.get(ofDuration(), "implWriteTimeout", defaultValue.hasImplWriteTimeout() ? defaultValue.getImplWriteTimeout() : null))) .andThen(applyIfNotNull( SocketSettings::withImplReadBufferSize, config.get(ofMemSize(), "implReadBufferSize", defaultValue.hasReadBufferSize() ? defaultValue.getImplReadBufferSize() : null))) .apply(SocketSettings.create()); } }; }  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; }