protected static void assertNumericArgument(long number, boolean zeroAllowed) { assertNumericArgument(number, zeroAllowed, Long.MAX_VALUE); }
/** * Configures a worker pool for the converter. This worker pool implicitly sets a maximum * number of conversions that are concurrently undertaken by the resulting converter. When a * converter is requested to concurrently execute more conversions than {@code maximumPoolSize}, * it will queue excess conversions until capacities are available again. * <p> </p> * If this number is set too low, the concurrent performance of the resulting converter will be weak * compared to a higher number. If this number is set too high, the converter might <i>overheat</i> * when accessing the underlying external resource (such as for example an external process or a * HTTP connection). A remote converter that shares a conversion server with another converter might * also starve these other remote converters. * * @param corePoolSize The core pool size of the worker pool. * @param maximumPoolSize The maximum pool size of the worker pool. * @param keepAliveTime The keep alive time of the worker pool. * @param unit The time unit of the specified keep alive time. * @return This builder instance. */ @SuppressWarnings("unchecked") public T workerPool(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit) { assertNumericArgument(corePoolSize, true); assertNumericArgument(maximumPoolSize, false); assertSmallerEquals(corePoolSize, maximumPoolSize); assertNumericArgument(keepAliveTime, true); assertNumericArgument(keepAliveTime, true); this.corePoolSize = corePoolSize; this.maximumPoolSize = maximumPoolSize; this.keepAliveTime = unit.toMillis(keepAliveTime); return (T) this; }