Class PoolConfig.Builder

  • Enclosing class:
    PoolConfig

    public static final class PoolConfig.Builder
    extends Object
    A builder for PoolConfig objects.
    Author:
    Rob Spoor
    • Method Detail

      • withMaxWaitTime

        public PoolConfig.Builder withMaxWaitTime​(Duration maxWaitTime)
        Sets the maximum time to wait when acquiring objects using Pool.acquire() or Pool.acquire(Supplier). If null or negative, acquiring objects should block until an object is available. The default is to wait indefinitely.
        Parameters:
        maxWaitTime - The maximum wait time.
        Returns:
        This builder.
      • withMaxIdleTime

        public PoolConfig.Builder withMaxIdleTime​(Duration maxIdleTime)
        Sets the maximum time that objects can be idle. The default is indefinitely.
        Parameters:
        maxIdleTime - The maximum idle time, or null if objects can be idle indefinitely.
        Returns:
        This builder.
      • withInitialSize

        public PoolConfig.Builder withInitialSize​(int initialSize)
        Sets the initial pool size. This is the number of idle objects to start with. The default is 1.

        If the maximum pool size is smaller than the given initial size, it will be set to be equal to the given initial size.

        Parameters:
        initialSize - The initial pool size.
        Returns:
        This builder.
        Throws:
        IllegalArgumentException - If the initial size is negative.
      • withMaxSize

        public PoolConfig.Builder withMaxSize​(int maxSize)
        Sets the maximum pool size. This is the maximum number of objects, both idle and currently in use. The default is 5.

        If the initial pool size is larger than the given maximum size, it will be set to be equal to the given maximum size.

        Parameters:
        maxSize - The maximum pool size.
        Returns:
        This builder.
        Throws:
        IllegalArgumentException - If the given size is not positive.