Class ConnectionConfig.Builder

java.lang.Object
com.lucimber.dbus.connection.ConnectionConfig.Builder
Enclosing class:
ConnectionConfig

public static final class ConnectionConfig.Builder extends Object
Builder class for creating ConnectionConfig instances.
  • Method Details

    • withMethodCallTimeout

      public ConnectionConfig.Builder withMethodCallTimeout(Duration timeout)
      Sets the timeout for method call responses.
      Parameters:
      timeout - The timeout duration (must be positive)
      Returns:
      This builder instance
      Throws:
      IllegalArgumentException - if timeout is null or not positive
    • withConnectTimeout

      public ConnectionConfig.Builder withConnectTimeout(Duration timeout)
      Sets the timeout for establishing connections.
      Parameters:
      timeout - The timeout duration (must be positive)
      Returns:
      This builder instance
      Throws:
      IllegalArgumentException - if timeout is null or not positive
    • withReadTimeout

      public ConnectionConfig.Builder withReadTimeout(Duration timeout)
      Sets the timeout for read operations.
      Parameters:
      timeout - The timeout duration (must be positive)
      Returns:
      This builder instance
      Throws:
      IllegalArgumentException - if timeout is null or not positive
    • withWriteTimeout

      public ConnectionConfig.Builder withWriteTimeout(Duration timeout)
      Sets the timeout for write operations.
      Parameters:
      timeout - The timeout duration (must be positive)
      Returns:
      This builder instance
      Throws:
      IllegalArgumentException - if timeout is null or not positive
    • withHealthCheckEnabled

      public ConnectionConfig.Builder withHealthCheckEnabled(boolean enabled)
      Sets whether health check monitoring is enabled.
      Parameters:
      enabled - true to enable health checks
      Returns:
      This builder instance
    • withHealthCheckInterval

      public ConnectionConfig.Builder withHealthCheckInterval(Duration interval)
      Sets the interval between health checks.
      Parameters:
      interval - The health check interval (must be positive)
      Returns:
      This builder instance
      Throws:
      IllegalArgumentException - if interval is null or not positive
    • withHealthCheckTimeout

      public ConnectionConfig.Builder withHealthCheckTimeout(Duration timeout)
      Sets the timeout for individual health checks.
      Parameters:
      timeout - The health check timeout (must be positive)
      Returns:
      This builder instance
      Throws:
      IllegalArgumentException - if timeout is null or not positive
    • withAutoReconnectEnabled

      public ConnectionConfig.Builder withAutoReconnectEnabled(boolean enabled)
      Sets whether automatic reconnection is enabled.
      Parameters:
      enabled - true to enable auto-reconnect
      Returns:
      This builder instance
    • withReconnectInitialDelay

      public ConnectionConfig.Builder withReconnectInitialDelay(Duration delay)
      Sets the initial delay before the first reconnection attempt.
      Parameters:
      delay - The initial reconnection delay (must be positive)
      Returns:
      This builder instance
      Throws:
      IllegalArgumentException - if delay is null or not positive
    • withReconnectMaxDelay

      public ConnectionConfig.Builder withReconnectMaxDelay(Duration delay)
      Sets the maximum delay between reconnection attempts.
      Parameters:
      delay - The maximum reconnection delay (must be positive)
      Returns:
      This builder instance
      Throws:
      IllegalArgumentException - if delay is null or not positive
    • withReconnectBackoffMultiplier

      public ConnectionConfig.Builder withReconnectBackoffMultiplier(double multiplier)
      Sets the backoff multiplier for reconnection delays.
      Parameters:
      multiplier - The backoff multiplier (must be >= 1.0)
      Returns:
      This builder instance
      Throws:
      IllegalArgumentException - if multiplier is less than 1.0
    • withMaxReconnectAttempts

      public ConnectionConfig.Builder withMaxReconnectAttempts(int attempts)
      Sets the maximum number of reconnection attempts.
      Parameters:
      attempts - The maximum reconnection attempts (must be >= 0, 0 means unlimited)
      Returns:
      This builder instance
      Throws:
      IllegalArgumentException - if attempts is negative
    • withCloseTimeout

      public ConnectionConfig.Builder withCloseTimeout(Duration timeout)
      Sets the timeout for connection close operations.
      Parameters:
      timeout - The close timeout duration (must be positive)
      Returns:
      This builder instance
      Throws:
      IllegalArgumentException - if timeout is null or not positive
    • build

      public ConnectionConfig build()
      Builds a new ConnectionConfig instance with the configured values.
      Returns:
      A new ConnectionConfig instance