- java.lang.Object
-
- com.github.robtimus.pool.PoolConfig.Builder
-
- Enclosing class:
- PoolConfig
public static final class PoolConfig.Builder extends Object
A builder forPoolConfig
objects.- Author:
- Rob Spoor
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PoolConfig
build()
Creates a newPoolConfig
object based on the settings of this builder.PoolConfig.Builder
withInitialSize(int initialSize)
Sets the initial pool size.PoolConfig.Builder
withMaxIdleTime(Duration maxIdleTime)
Sets the maximum time that objects can be idle.PoolConfig.Builder
withMaxSize(int maxSize)
Sets the maximum pool size.PoolConfig.Builder
withMaxWaitTime(Duration maxWaitTime)
Sets the maximum time to wait when acquiring objects usingPool.acquire()
orPool.acquire(Supplier)
.
-
-
-
Method Detail
-
withMaxWaitTime
public PoolConfig.Builder withMaxWaitTime(Duration maxWaitTime)
Sets the maximum time to wait when acquiring objects usingPool.acquire()
orPool.acquire(Supplier)
. Ifnull
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, ornull
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.
-
build
public PoolConfig build()
Creates a newPoolConfig
object based on the settings of this builder.- Returns:
- The created
PoolConfig
object.
-
-