
com.github.jcustenborder.kafka.connect.client.ImmutableSettings Maven / Gradle / Ivy
package com.github.jcustenborder.kafka.connect.client;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import org.immutables.value.Generated;
/**
* Immutable implementation of {@link KafkaConnectClient.Settings}.
*
* Use the builder to create immutable instances:
* {@code ImmutableSettings.builder()}.
* Use the static factory method to create immutable instances:
* {@code ImmutableSettings.of()}.
*/
@Generated(from = "KafkaConnectClient.Settings", generator = "Immutables")
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
@CheckReturnValue
final class ImmutableSettings
extends KafkaConnectClient.Settings {
private final String host;
private final int port;
private final String scheme;
private final @Nullable String username;
private final @Nullable String password;
private final Duration callTimeout;
private final Duration connectTimeout;
private final Duration writeTimeout;
private final Duration readTimeout;
private final int retries;
private final Duration delayBetweenAttempts;
private final OkHttpClient client;
private transient final HttpUrl baseUrl;
private transient final @Nullable String credentials;
private transient final boolean hasCredentials;
private transient final ObjectMapper objectMapper;
private transient final long delayAsMilliseconds;
private final ScheduledExecutorService scheduler;
private final boolean shutdownSchedulerOnClose;
private ImmutableSettings(
String host,
int port,
String scheme,
@Nullable String username,
@Nullable String password,
Duration callTimeout,
Duration connectTimeout,
Duration writeTimeout,
Duration readTimeout,
int retries,
Duration delayBetweenAttempts,
OkHttpClient client,
ScheduledExecutorService scheduler,
boolean shutdownSchedulerOnClose) {
initShim.host(Objects.requireNonNull(host, "host"));
initShim.port(port);
initShim.scheme(Objects.requireNonNull(scheme, "scheme"));
initShim.username(username);
initShim.password(password);
initShim.callTimeout(Objects.requireNonNull(callTimeout, "callTimeout"));
initShim.connectTimeout(Objects.requireNonNull(connectTimeout, "connectTimeout"));
initShim.writeTimeout(Objects.requireNonNull(writeTimeout, "writeTimeout"));
initShim.readTimeout(Objects.requireNonNull(readTimeout, "readTimeout"));
initShim.retries(retries);
initShim.delayBetweenAttempts(Objects.requireNonNull(delayBetweenAttempts, "delayBetweenAttempts"));
initShim.client(Objects.requireNonNull(client, "client"));
initShim.scheduler(Objects.requireNonNull(scheduler, "scheduler"));
initShim.shutdownSchedulerOnClose(shutdownSchedulerOnClose);
this.host = initShim.host();
this.port = initShim.port();
this.scheme = initShim.scheme();
this.username = initShim.username();
this.password = initShim.password();
this.callTimeout = initShim.callTimeout();
this.connectTimeout = initShim.connectTimeout();
this.writeTimeout = initShim.writeTimeout();
this.readTimeout = initShim.readTimeout();
this.retries = initShim.retries();
this.delayBetweenAttempts = initShim.delayBetweenAttempts();
this.client = initShim.client();
this.baseUrl = initShim.baseUrl();
this.credentials = initShim.credentials();
this.hasCredentials = initShim.hasCredentials();
this.objectMapper = initShim.objectMapper();
this.delayAsMilliseconds = initShim.delayAsMilliseconds();
this.scheduler = initShim.scheduler();
this.shutdownSchedulerOnClose = initShim.shutdownSchedulerOnClose();
this.initShim = null;
}
private ImmutableSettings(ImmutableSettings.Builder builder) {
if (builder.host != null) {
initShim.host(builder.host);
}
if (builder.portIsSet()) {
initShim.port(builder.port);
}
if (builder.scheme != null) {
initShim.scheme(builder.scheme);
}
if (builder.usernameIsSet()) {
initShim.username(builder.username);
}
if (builder.passwordIsSet()) {
initShim.password(builder.password);
}
if (builder.callTimeout != null) {
initShim.callTimeout(builder.callTimeout);
}
if (builder.connectTimeout != null) {
initShim.connectTimeout(builder.connectTimeout);
}
if (builder.writeTimeout != null) {
initShim.writeTimeout(builder.writeTimeout);
}
if (builder.readTimeout != null) {
initShim.readTimeout(builder.readTimeout);
}
if (builder.retriesIsSet()) {
initShim.retries(builder.retries);
}
if (builder.delayBetweenAttempts != null) {
initShim.delayBetweenAttempts(builder.delayBetweenAttempts);
}
if (builder.client != null) {
initShim.client(builder.client);
}
if (builder.scheduler != null) {
initShim.scheduler(builder.scheduler);
}
if (builder.shutdownSchedulerOnCloseIsSet()) {
initShim.shutdownSchedulerOnClose(builder.shutdownSchedulerOnClose);
}
this.host = initShim.host();
this.port = initShim.port();
this.scheme = initShim.scheme();
this.username = initShim.username();
this.password = initShim.password();
this.callTimeout = initShim.callTimeout();
this.connectTimeout = initShim.connectTimeout();
this.writeTimeout = initShim.writeTimeout();
this.readTimeout = initShim.readTimeout();
this.retries = initShim.retries();
this.delayBetweenAttempts = initShim.delayBetweenAttempts();
this.client = initShim.client();
this.baseUrl = initShim.baseUrl();
this.credentials = initShim.credentials();
this.hasCredentials = initShim.hasCredentials();
this.objectMapper = initShim.objectMapper();
this.delayAsMilliseconds = initShim.delayAsMilliseconds();
this.scheduler = initShim.scheduler();
this.shutdownSchedulerOnClose = initShim.shutdownSchedulerOnClose();
this.initShim = null;
}
private ImmutableSettings(
ImmutableSettings original,
String host,
int port,
String scheme,
@Nullable String username,
@Nullable String password,
Duration callTimeout,
Duration connectTimeout,
Duration writeTimeout,
Duration readTimeout,
int retries,
Duration delayBetweenAttempts,
OkHttpClient client,
ScheduledExecutorService scheduler,
boolean shutdownSchedulerOnClose) {
initShim.host(host);
initShim.port(port);
initShim.scheme(scheme);
initShim.username(username);
initShim.password(password);
initShim.callTimeout(callTimeout);
initShim.connectTimeout(connectTimeout);
initShim.writeTimeout(writeTimeout);
initShim.readTimeout(readTimeout);
initShim.retries(retries);
initShim.delayBetweenAttempts(delayBetweenAttempts);
initShim.client(client);
initShim.scheduler(scheduler);
initShim.shutdownSchedulerOnClose(shutdownSchedulerOnClose);
this.host = initShim.host();
this.port = initShim.port();
this.scheme = initShim.scheme();
this.username = initShim.username();
this.password = initShim.password();
this.callTimeout = initShim.callTimeout();
this.connectTimeout = initShim.connectTimeout();
this.writeTimeout = initShim.writeTimeout();
this.readTimeout = initShim.readTimeout();
this.retries = initShim.retries();
this.delayBetweenAttempts = initShim.delayBetweenAttempts();
this.client = initShim.client();
this.baseUrl = initShim.baseUrl();
this.credentials = initShim.credentials();
this.hasCredentials = initShim.hasCredentials();
this.objectMapper = initShim.objectMapper();
this.delayAsMilliseconds = initShim.delayAsMilliseconds();
this.scheduler = initShim.scheduler();
this.shutdownSchedulerOnClose = initShim.shutdownSchedulerOnClose();
this.initShim = null;
}
private static final byte STAGE_INITIALIZING = -1;
private static final byte STAGE_UNINITIALIZED = 0;
private static final byte STAGE_INITIALIZED = 1;
@SuppressWarnings("Immutable")
private transient volatile InitShim initShim = new InitShim();
@Generated(from = "KafkaConnectClient.Settings", generator = "Immutables")
private final class InitShim {
private byte hostBuildStage = STAGE_UNINITIALIZED;
private String host;
String host() {
if (hostBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (hostBuildStage == STAGE_UNINITIALIZED) {
hostBuildStage = STAGE_INITIALIZING;
this.host = Objects.requireNonNull(ImmutableSettings.super.host(), "host");
hostBuildStage = STAGE_INITIALIZED;
}
return this.host;
}
void host(String host) {
this.host = host;
hostBuildStage = STAGE_INITIALIZED;
}
private byte portBuildStage = STAGE_UNINITIALIZED;
private int port;
int port() {
if (portBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (portBuildStage == STAGE_UNINITIALIZED) {
portBuildStage = STAGE_INITIALIZING;
this.port = ImmutableSettings.super.port();
portBuildStage = STAGE_INITIALIZED;
}
return this.port;
}
void port(int port) {
this.port = port;
portBuildStage = STAGE_INITIALIZED;
}
private byte schemeBuildStage = STAGE_UNINITIALIZED;
private String scheme;
String scheme() {
if (schemeBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (schemeBuildStage == STAGE_UNINITIALIZED) {
schemeBuildStage = STAGE_INITIALIZING;
this.scheme = Objects.requireNonNull(ImmutableSettings.super.scheme(), "scheme");
schemeBuildStage = STAGE_INITIALIZED;
}
return this.scheme;
}
void scheme(String scheme) {
this.scheme = scheme;
schemeBuildStage = STAGE_INITIALIZED;
}
private byte usernameBuildStage = STAGE_UNINITIALIZED;
private String username;
String username() {
if (usernameBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (usernameBuildStage == STAGE_UNINITIALIZED) {
usernameBuildStage = STAGE_INITIALIZING;
this.username = ImmutableSettings.super.username();
usernameBuildStage = STAGE_INITIALIZED;
}
return this.username;
}
void username(String username) {
this.username = username;
usernameBuildStage = STAGE_INITIALIZED;
}
private byte passwordBuildStage = STAGE_UNINITIALIZED;
private String password;
String password() {
if (passwordBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (passwordBuildStage == STAGE_UNINITIALIZED) {
passwordBuildStage = STAGE_INITIALIZING;
this.password = ImmutableSettings.super.password();
passwordBuildStage = STAGE_INITIALIZED;
}
return this.password;
}
void password(String password) {
this.password = password;
passwordBuildStage = STAGE_INITIALIZED;
}
private byte callTimeoutBuildStage = STAGE_UNINITIALIZED;
private Duration callTimeout;
Duration callTimeout() {
if (callTimeoutBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (callTimeoutBuildStage == STAGE_UNINITIALIZED) {
callTimeoutBuildStage = STAGE_INITIALIZING;
this.callTimeout = Objects.requireNonNull(ImmutableSettings.super.callTimeout(), "callTimeout");
callTimeoutBuildStage = STAGE_INITIALIZED;
}
return this.callTimeout;
}
void callTimeout(Duration callTimeout) {
this.callTimeout = callTimeout;
callTimeoutBuildStage = STAGE_INITIALIZED;
}
private byte connectTimeoutBuildStage = STAGE_UNINITIALIZED;
private Duration connectTimeout;
Duration connectTimeout() {
if (connectTimeoutBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (connectTimeoutBuildStage == STAGE_UNINITIALIZED) {
connectTimeoutBuildStage = STAGE_INITIALIZING;
this.connectTimeout = Objects.requireNonNull(ImmutableSettings.super.connectTimeout(), "connectTimeout");
connectTimeoutBuildStage = STAGE_INITIALIZED;
}
return this.connectTimeout;
}
void connectTimeout(Duration connectTimeout) {
this.connectTimeout = connectTimeout;
connectTimeoutBuildStage = STAGE_INITIALIZED;
}
private byte writeTimeoutBuildStage = STAGE_UNINITIALIZED;
private Duration writeTimeout;
Duration writeTimeout() {
if (writeTimeoutBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (writeTimeoutBuildStage == STAGE_UNINITIALIZED) {
writeTimeoutBuildStage = STAGE_INITIALIZING;
this.writeTimeout = Objects.requireNonNull(ImmutableSettings.super.writeTimeout(), "writeTimeout");
writeTimeoutBuildStage = STAGE_INITIALIZED;
}
return this.writeTimeout;
}
void writeTimeout(Duration writeTimeout) {
this.writeTimeout = writeTimeout;
writeTimeoutBuildStage = STAGE_INITIALIZED;
}
private byte readTimeoutBuildStage = STAGE_UNINITIALIZED;
private Duration readTimeout;
Duration readTimeout() {
if (readTimeoutBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (readTimeoutBuildStage == STAGE_UNINITIALIZED) {
readTimeoutBuildStage = STAGE_INITIALIZING;
this.readTimeout = Objects.requireNonNull(ImmutableSettings.super.readTimeout(), "readTimeout");
readTimeoutBuildStage = STAGE_INITIALIZED;
}
return this.readTimeout;
}
void readTimeout(Duration readTimeout) {
this.readTimeout = readTimeout;
readTimeoutBuildStage = STAGE_INITIALIZED;
}
private byte retriesBuildStage = STAGE_UNINITIALIZED;
private int retries;
int retries() {
if (retriesBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (retriesBuildStage == STAGE_UNINITIALIZED) {
retriesBuildStage = STAGE_INITIALIZING;
this.retries = ImmutableSettings.super.retries();
retriesBuildStage = STAGE_INITIALIZED;
}
return this.retries;
}
void retries(int retries) {
this.retries = retries;
retriesBuildStage = STAGE_INITIALIZED;
}
private byte delayBetweenAttemptsBuildStage = STAGE_UNINITIALIZED;
private Duration delayBetweenAttempts;
Duration delayBetweenAttempts() {
if (delayBetweenAttemptsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (delayBetweenAttemptsBuildStage == STAGE_UNINITIALIZED) {
delayBetweenAttemptsBuildStage = STAGE_INITIALIZING;
this.delayBetweenAttempts = Objects.requireNonNull(ImmutableSettings.super.delayBetweenAttempts(), "delayBetweenAttempts");
delayBetweenAttemptsBuildStage = STAGE_INITIALIZED;
}
return this.delayBetweenAttempts;
}
void delayBetweenAttempts(Duration delayBetweenAttempts) {
this.delayBetweenAttempts = delayBetweenAttempts;
delayBetweenAttemptsBuildStage = STAGE_INITIALIZED;
}
private byte clientBuildStage = STAGE_UNINITIALIZED;
private OkHttpClient client;
OkHttpClient client() {
if (clientBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (clientBuildStage == STAGE_UNINITIALIZED) {
clientBuildStage = STAGE_INITIALIZING;
this.client = Objects.requireNonNull(ImmutableSettings.super.client(), "client");
clientBuildStage = STAGE_INITIALIZED;
}
return this.client;
}
void client(OkHttpClient client) {
this.client = client;
clientBuildStage = STAGE_INITIALIZED;
}
private byte baseUrlBuildStage = STAGE_UNINITIALIZED;
private HttpUrl baseUrl;
HttpUrl baseUrl() {
if (baseUrlBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (baseUrlBuildStage == STAGE_UNINITIALIZED) {
baseUrlBuildStage = STAGE_INITIALIZING;
this.baseUrl = Objects.requireNonNull(ImmutableSettings.super.baseUrl(), "baseUrl");
baseUrlBuildStage = STAGE_INITIALIZED;
}
return this.baseUrl;
}
private byte credentialsBuildStage = STAGE_UNINITIALIZED;
private String credentials;
String credentials() {
if (credentialsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (credentialsBuildStage == STAGE_UNINITIALIZED) {
credentialsBuildStage = STAGE_INITIALIZING;
this.credentials = ImmutableSettings.super.credentials();
credentialsBuildStage = STAGE_INITIALIZED;
}
return this.credentials;
}
private byte hasCredentialsBuildStage = STAGE_UNINITIALIZED;
private boolean hasCredentials;
boolean hasCredentials() {
if (hasCredentialsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (hasCredentialsBuildStage == STAGE_UNINITIALIZED) {
hasCredentialsBuildStage = STAGE_INITIALIZING;
this.hasCredentials = ImmutableSettings.super.hasCredentials();
hasCredentialsBuildStage = STAGE_INITIALIZED;
}
return this.hasCredentials;
}
private byte objectMapperBuildStage = STAGE_UNINITIALIZED;
private ObjectMapper objectMapper;
ObjectMapper objectMapper() {
if (objectMapperBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (objectMapperBuildStage == STAGE_UNINITIALIZED) {
objectMapperBuildStage = STAGE_INITIALIZING;
this.objectMapper = Objects.requireNonNull(ImmutableSettings.super.objectMapper(), "objectMapper");
objectMapperBuildStage = STAGE_INITIALIZED;
}
return this.objectMapper;
}
private byte delayAsMillisecondsBuildStage = STAGE_UNINITIALIZED;
private long delayAsMilliseconds;
long delayAsMilliseconds() {
if (delayAsMillisecondsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (delayAsMillisecondsBuildStage == STAGE_UNINITIALIZED) {
delayAsMillisecondsBuildStage = STAGE_INITIALIZING;
this.delayAsMilliseconds = ImmutableSettings.super.delayAsMilliseconds();
delayAsMillisecondsBuildStage = STAGE_INITIALIZED;
}
return this.delayAsMilliseconds;
}
private byte schedulerBuildStage = STAGE_UNINITIALIZED;
private ScheduledExecutorService scheduler;
ScheduledExecutorService scheduler() {
if (schedulerBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (schedulerBuildStage == STAGE_UNINITIALIZED) {
schedulerBuildStage = STAGE_INITIALIZING;
this.scheduler = Objects.requireNonNull(ImmutableSettings.super.scheduler(), "scheduler");
schedulerBuildStage = STAGE_INITIALIZED;
}
return this.scheduler;
}
void scheduler(ScheduledExecutorService scheduler) {
this.scheduler = scheduler;
schedulerBuildStage = STAGE_INITIALIZED;
}
private byte shutdownSchedulerOnCloseBuildStage = STAGE_UNINITIALIZED;
private boolean shutdownSchedulerOnClose;
boolean shutdownSchedulerOnClose() {
if (shutdownSchedulerOnCloseBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (shutdownSchedulerOnCloseBuildStage == STAGE_UNINITIALIZED) {
shutdownSchedulerOnCloseBuildStage = STAGE_INITIALIZING;
this.shutdownSchedulerOnClose = ImmutableSettings.super.shutdownSchedulerOnClose();
shutdownSchedulerOnCloseBuildStage = STAGE_INITIALIZED;
}
return this.shutdownSchedulerOnClose;
}
void shutdownSchedulerOnClose(boolean shutdownSchedulerOnClose) {
this.shutdownSchedulerOnClose = shutdownSchedulerOnClose;
shutdownSchedulerOnCloseBuildStage = STAGE_INITIALIZED;
}
private String formatInitCycleMessage() {
List attributes = new ArrayList<>();
if (hostBuildStage == STAGE_INITIALIZING) attributes.add("host");
if (portBuildStage == STAGE_INITIALIZING) attributes.add("port");
if (schemeBuildStage == STAGE_INITIALIZING) attributes.add("scheme");
if (usernameBuildStage == STAGE_INITIALIZING) attributes.add("username");
if (passwordBuildStage == STAGE_INITIALIZING) attributes.add("password");
if (callTimeoutBuildStage == STAGE_INITIALIZING) attributes.add("callTimeout");
if (connectTimeoutBuildStage == STAGE_INITIALIZING) attributes.add("connectTimeout");
if (writeTimeoutBuildStage == STAGE_INITIALIZING) attributes.add("writeTimeout");
if (readTimeoutBuildStage == STAGE_INITIALIZING) attributes.add("readTimeout");
if (retriesBuildStage == STAGE_INITIALIZING) attributes.add("retries");
if (delayBetweenAttemptsBuildStage == STAGE_INITIALIZING) attributes.add("delayBetweenAttempts");
if (clientBuildStage == STAGE_INITIALIZING) attributes.add("client");
if (baseUrlBuildStage == STAGE_INITIALIZING) attributes.add("baseUrl");
if (credentialsBuildStage == STAGE_INITIALIZING) attributes.add("credentials");
if (hasCredentialsBuildStage == STAGE_INITIALIZING) attributes.add("hasCredentials");
if (objectMapperBuildStage == STAGE_INITIALIZING) attributes.add("objectMapper");
if (delayAsMillisecondsBuildStage == STAGE_INITIALIZING) attributes.add("delayAsMilliseconds");
if (schedulerBuildStage == STAGE_INITIALIZING) attributes.add("scheduler");
if (shutdownSchedulerOnCloseBuildStage == STAGE_INITIALIZING) attributes.add("shutdownSchedulerOnClose");
return "Cannot build Settings, attribute initializers form cycle " + attributes;
}
}
/**
* @return The value of the {@code host} attribute
*/
@Override
public String host() {
InitShim shim = this.initShim;
return shim != null
? shim.host()
: this.host;
}
/**
* @return The value of the {@code port} attribute
*/
@Override
public int port() {
InitShim shim = this.initShim;
return shim != null
? shim.port()
: this.port;
}
/**
* @return The value of the {@code scheme} attribute
*/
@Override
public String scheme() {
InitShim shim = this.initShim;
return shim != null
? shim.scheme()
: this.scheme;
}
/**
* @return The value of the {@code username} attribute
*/
@Override
public @Nullable String username() {
InitShim shim = this.initShim;
return shim != null
? shim.username()
: this.username;
}
/**
* @return The value of the {@code password} attribute
*/
@Override
public @Nullable String password() {
InitShim shim = this.initShim;
return shim != null
? shim.password()
: this.password;
}
/**
* @return The value of the {@code callTimeout} attribute
*/
@Override
public Duration callTimeout() {
InitShim shim = this.initShim;
return shim != null
? shim.callTimeout()
: this.callTimeout;
}
/**
* @return The value of the {@code connectTimeout} attribute
*/
@Override
public Duration connectTimeout() {
InitShim shim = this.initShim;
return shim != null
? shim.connectTimeout()
: this.connectTimeout;
}
/**
* @return The value of the {@code writeTimeout} attribute
*/
@Override
public Duration writeTimeout() {
InitShim shim = this.initShim;
return shim != null
? shim.writeTimeout()
: this.writeTimeout;
}
/**
* @return The value of the {@code readTimeout} attribute
*/
@Override
public Duration readTimeout() {
InitShim shim = this.initShim;
return shim != null
? shim.readTimeout()
: this.readTimeout;
}
/**
* @return The value of the {@code retries} attribute
*/
@Override
public int retries() {
InitShim shim = this.initShim;
return shim != null
? shim.retries()
: this.retries;
}
/**
* @return The value of the {@code delayBetweenAttempts} attribute
*/
@Override
public Duration delayBetweenAttempts() {
InitShim shim = this.initShim;
return shim != null
? shim.delayBetweenAttempts()
: this.delayBetweenAttempts;
}
/**
* @return The value of the {@code client} attribute
*/
@Override
public OkHttpClient client() {
InitShim shim = this.initShim;
return shim != null
? shim.client()
: this.client;
}
/**
* @return The computed-at-construction value of the {@code baseUrl} attribute
*/
@Override
HttpUrl baseUrl() {
InitShim shim = this.initShim;
return shim != null
? shim.baseUrl()
: this.baseUrl;
}
/**
* @return The computed-at-construction value of the {@code credentials} attribute
*/
@Override
@Nullable String credentials() {
InitShim shim = this.initShim;
return shim != null
? shim.credentials()
: this.credentials;
}
/**
* @return The computed-at-construction value of the {@code hasCredentials} attribute
*/
@Override
boolean hasCredentials() {
InitShim shim = this.initShim;
return shim != null
? shim.hasCredentials()
: this.hasCredentials;
}
/**
* @return The computed-at-construction value of the {@code objectMapper} attribute
*/
@Override
ObjectMapper objectMapper() {
InitShim shim = this.initShim;
return shim != null
? shim.objectMapper()
: this.objectMapper;
}
/**
* @return The computed-at-construction value of the {@code delayAsMilliseconds} attribute
*/
@Override
long delayAsMilliseconds() {
InitShim shim = this.initShim;
return shim != null
? shim.delayAsMilliseconds()
: this.delayAsMilliseconds;
}
/**
* @return The value of the {@code scheduler} attribute
*/
@Override
public ScheduledExecutorService scheduler() {
InitShim shim = this.initShim;
return shim != null
? shim.scheduler()
: this.scheduler;
}
/**
* @return The value of the {@code shutdownSchedulerOnClose} attribute
*/
@Override
public boolean shutdownSchedulerOnClose() {
InitShim shim = this.initShim;
return shim != null
? shim.shutdownSchedulerOnClose()
: this.shutdownSchedulerOnClose;
}
/**
* Copy the current immutable object by setting a value for the {@link KafkaConnectClient.Settings#host() host} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for host
* @return A modified copy of the {@code this} object
*/
public final ImmutableSettings withHost(String value) {
String newValue = Objects.requireNonNull(value, "host");
if (this.host.equals(newValue)) return this;
return new ImmutableSettings(
this,
newValue,
this.port,
this.scheme,
this.username,
this.password,
this.callTimeout,
this.connectTimeout,
this.writeTimeout,
this.readTimeout,
this.retries,
this.delayBetweenAttempts,
this.client,
this.scheduler,
this.shutdownSchedulerOnClose);
}
/**
* Copy the current immutable object by setting a value for the {@link KafkaConnectClient.Settings#port() port} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for port
* @return A modified copy of the {@code this} object
*/
public final ImmutableSettings withPort(int value) {
if (this.port == value) return this;
return new ImmutableSettings(
this,
this.host,
value,
this.scheme,
this.username,
this.password,
this.callTimeout,
this.connectTimeout,
this.writeTimeout,
this.readTimeout,
this.retries,
this.delayBetweenAttempts,
this.client,
this.scheduler,
this.shutdownSchedulerOnClose);
}
/**
* Copy the current immutable object by setting a value for the {@link KafkaConnectClient.Settings#scheme() scheme} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for scheme
* @return A modified copy of the {@code this} object
*/
public final ImmutableSettings withScheme(String value) {
String newValue = Objects.requireNonNull(value, "scheme");
if (this.scheme.equals(newValue)) return this;
return new ImmutableSettings(
this,
this.host,
this.port,
newValue,
this.username,
this.password,
this.callTimeout,
this.connectTimeout,
this.writeTimeout,
this.readTimeout,
this.retries,
this.delayBetweenAttempts,
this.client,
this.scheduler,
this.shutdownSchedulerOnClose);
}
/**
* Copy the current immutable object by setting a value for the {@link KafkaConnectClient.Settings#username() username} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for username (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableSettings withUsername(@Nullable String value) {
if (Objects.equals(this.username, value)) return this;
return new ImmutableSettings(
this,
this.host,
this.port,
this.scheme,
value,
this.password,
this.callTimeout,
this.connectTimeout,
this.writeTimeout,
this.readTimeout,
this.retries,
this.delayBetweenAttempts,
this.client,
this.scheduler,
this.shutdownSchedulerOnClose);
}
/**
* Copy the current immutable object by setting a value for the {@link KafkaConnectClient.Settings#password() password} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for password (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableSettings withPassword(@Nullable String value) {
if (Objects.equals(this.password, value)) return this;
return new ImmutableSettings(
this,
this.host,
this.port,
this.scheme,
this.username,
value,
this.callTimeout,
this.connectTimeout,
this.writeTimeout,
this.readTimeout,
this.retries,
this.delayBetweenAttempts,
this.client,
this.scheduler,
this.shutdownSchedulerOnClose);
}
/**
* Copy the current immutable object by setting a value for the {@link KafkaConnectClient.Settings#callTimeout() callTimeout} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for callTimeout
* @return A modified copy of the {@code this} object
*/
public final ImmutableSettings withCallTimeout(Duration value) {
if (this.callTimeout == value) return this;
Duration newValue = Objects.requireNonNull(value, "callTimeout");
return new ImmutableSettings(
this,
this.host,
this.port,
this.scheme,
this.username,
this.password,
newValue,
this.connectTimeout,
this.writeTimeout,
this.readTimeout,
this.retries,
this.delayBetweenAttempts,
this.client,
this.scheduler,
this.shutdownSchedulerOnClose);
}
/**
* Copy the current immutable object by setting a value for the {@link KafkaConnectClient.Settings#connectTimeout() connectTimeout} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for connectTimeout
* @return A modified copy of the {@code this} object
*/
public final ImmutableSettings withConnectTimeout(Duration value) {
if (this.connectTimeout == value) return this;
Duration newValue = Objects.requireNonNull(value, "connectTimeout");
return new ImmutableSettings(
this,
this.host,
this.port,
this.scheme,
this.username,
this.password,
this.callTimeout,
newValue,
this.writeTimeout,
this.readTimeout,
this.retries,
this.delayBetweenAttempts,
this.client,
this.scheduler,
this.shutdownSchedulerOnClose);
}
/**
* Copy the current immutable object by setting a value for the {@link KafkaConnectClient.Settings#writeTimeout() writeTimeout} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for writeTimeout
* @return A modified copy of the {@code this} object
*/
public final ImmutableSettings withWriteTimeout(Duration value) {
if (this.writeTimeout == value) return this;
Duration newValue = Objects.requireNonNull(value, "writeTimeout");
return new ImmutableSettings(
this,
this.host,
this.port,
this.scheme,
this.username,
this.password,
this.callTimeout,
this.connectTimeout,
newValue,
this.readTimeout,
this.retries,
this.delayBetweenAttempts,
this.client,
this.scheduler,
this.shutdownSchedulerOnClose);
}
/**
* Copy the current immutable object by setting a value for the {@link KafkaConnectClient.Settings#readTimeout() readTimeout} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for readTimeout
* @return A modified copy of the {@code this} object
*/
public final ImmutableSettings withReadTimeout(Duration value) {
if (this.readTimeout == value) return this;
Duration newValue = Objects.requireNonNull(value, "readTimeout");
return new ImmutableSettings(
this,
this.host,
this.port,
this.scheme,
this.username,
this.password,
this.callTimeout,
this.connectTimeout,
this.writeTimeout,
newValue,
this.retries,
this.delayBetweenAttempts,
this.client,
this.scheduler,
this.shutdownSchedulerOnClose);
}
/**
* Copy the current immutable object by setting a value for the {@link KafkaConnectClient.Settings#retries() retries} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for retries
* @return A modified copy of the {@code this} object
*/
public final ImmutableSettings withRetries(int value) {
if (this.retries == value) return this;
return new ImmutableSettings(
this,
this.host,
this.port,
this.scheme,
this.username,
this.password,
this.callTimeout,
this.connectTimeout,
this.writeTimeout,
this.readTimeout,
value,
this.delayBetweenAttempts,
this.client,
this.scheduler,
this.shutdownSchedulerOnClose);
}
/**
* Copy the current immutable object by setting a value for the {@link KafkaConnectClient.Settings#delayBetweenAttempts() delayBetweenAttempts} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for delayBetweenAttempts
* @return A modified copy of the {@code this} object
*/
public final ImmutableSettings withDelayBetweenAttempts(Duration value) {
if (this.delayBetweenAttempts == value) return this;
Duration newValue = Objects.requireNonNull(value, "delayBetweenAttempts");
return new ImmutableSettings(
this,
this.host,
this.port,
this.scheme,
this.username,
this.password,
this.callTimeout,
this.connectTimeout,
this.writeTimeout,
this.readTimeout,
this.retries,
newValue,
this.client,
this.scheduler,
this.shutdownSchedulerOnClose);
}
/**
* Copy the current immutable object by setting a value for the {@link KafkaConnectClient.Settings#client() client} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for client
* @return A modified copy of the {@code this} object
*/
public final ImmutableSettings withClient(OkHttpClient value) {
if (this.client == value) return this;
OkHttpClient newValue = Objects.requireNonNull(value, "client");
return new ImmutableSettings(
this,
this.host,
this.port,
this.scheme,
this.username,
this.password,
this.callTimeout,
this.connectTimeout,
this.writeTimeout,
this.readTimeout,
this.retries,
this.delayBetweenAttempts,
newValue,
this.scheduler,
this.shutdownSchedulerOnClose);
}
/**
* Copy the current immutable object by setting a value for the {@link KafkaConnectClient.Settings#scheduler() scheduler} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for scheduler
* @return A modified copy of the {@code this} object
*/
public final ImmutableSettings withScheduler(ScheduledExecutorService value) {
if (this.scheduler == value) return this;
ScheduledExecutorService newValue = Objects.requireNonNull(value, "scheduler");
return new ImmutableSettings(
this,
this.host,
this.port,
this.scheme,
this.username,
this.password,
this.callTimeout,
this.connectTimeout,
this.writeTimeout,
this.readTimeout,
this.retries,
this.delayBetweenAttempts,
this.client,
newValue,
this.shutdownSchedulerOnClose);
}
/**
* Copy the current immutable object by setting a value for the {@link KafkaConnectClient.Settings#shutdownSchedulerOnClose() shutdownSchedulerOnClose} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for shutdownSchedulerOnClose
* @return A modified copy of the {@code this} object
*/
public final ImmutableSettings withShutdownSchedulerOnClose(boolean value) {
if (this.shutdownSchedulerOnClose == value) return this;
return new ImmutableSettings(
this,
this.host,
this.port,
this.scheme,
this.username,
this.password,
this.callTimeout,
this.connectTimeout,
this.writeTimeout,
this.readTimeout,
this.retries,
this.delayBetweenAttempts,
this.client,
this.scheduler,
value);
}
/**
* This instance is equal to all instances of {@code ImmutableSettings} that have equal attribute values.
* @return {@code true} if {@code this} is equal to {@code another} instance
*/
@Override
public boolean equals(@Nullable Object another) {
if (this == another) return true;
return another instanceof ImmutableSettings
&& equalTo((ImmutableSettings) another);
}
private boolean equalTo(ImmutableSettings another) {
return host.equals(another.host)
&& port == another.port
&& scheme.equals(another.scheme)
&& Objects.equals(username, another.username)
&& Objects.equals(password, another.password)
&& callTimeout.equals(another.callTimeout)
&& connectTimeout.equals(another.connectTimeout)
&& writeTimeout.equals(another.writeTimeout)
&& readTimeout.equals(another.readTimeout)
&& retries == another.retries
&& delayBetweenAttempts.equals(another.delayBetweenAttempts)
&& client.equals(another.client)
&& baseUrl.equals(another.baseUrl)
&& Objects.equals(credentials, another.credentials)
&& hasCredentials == another.hasCredentials
&& objectMapper.equals(another.objectMapper)
&& delayAsMilliseconds == another.delayAsMilliseconds
&& scheduler.equals(another.scheduler)
&& shutdownSchedulerOnClose == another.shutdownSchedulerOnClose;
}
/**
* Computes a hash code from attributes: {@code host}, {@code port}, {@code scheme}, {@code username}, {@code password}, {@code callTimeout}, {@code connectTimeout}, {@code writeTimeout}, {@code readTimeout}, {@code retries}, {@code delayBetweenAttempts}, {@code client}, {@code baseUrl}, {@code credentials}, {@code hasCredentials}, {@code objectMapper}, {@code delayAsMilliseconds}, {@code scheduler}, {@code shutdownSchedulerOnClose}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + host.hashCode();
h += (h << 5) + port;
h += (h << 5) + scheme.hashCode();
h += (h << 5) + Objects.hashCode(username);
h += (h << 5) + Objects.hashCode(password);
h += (h << 5) + callTimeout.hashCode();
h += (h << 5) + connectTimeout.hashCode();
h += (h << 5) + writeTimeout.hashCode();
h += (h << 5) + readTimeout.hashCode();
h += (h << 5) + retries;
h += (h << 5) + delayBetweenAttempts.hashCode();
h += (h << 5) + client.hashCode();
h += (h << 5) + baseUrl.hashCode();
h += (h << 5) + Objects.hashCode(credentials);
h += (h << 5) + Boolean.hashCode(hasCredentials);
h += (h << 5) + objectMapper.hashCode();
h += (h << 5) + Long.hashCode(delayAsMilliseconds);
h += (h << 5) + scheduler.hashCode();
h += (h << 5) + Boolean.hashCode(shutdownSchedulerOnClose);
return h;
}
/**
* Prints the immutable value {@code Settings} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return "Settings{"
+ "host=" + host
+ ", port=" + port
+ ", scheme=" + scheme
+ ", username=" + username
+ ", password=" + password
+ ", callTimeout=" + callTimeout
+ ", connectTimeout=" + connectTimeout
+ ", writeTimeout=" + writeTimeout
+ ", readTimeout=" + readTimeout
+ ", retries=" + retries
+ ", delayBetweenAttempts=" + delayBetweenAttempts
+ ", client=" + client
+ ", baseUrl=" + baseUrl
+ ", credentials=" + credentials
+ ", hasCredentials=" + hasCredentials
+ ", objectMapper=" + objectMapper
+ ", delayAsMilliseconds=" + delayAsMilliseconds
+ ", scheduler=" + scheduler
+ ", shutdownSchedulerOnClose=" + shutdownSchedulerOnClose
+ "}";
}
/**
* Construct a new immutable {@code Settings} instance.
* @param host The value for the {@code host} attribute
* @param port The value for the {@code port} attribute
* @param scheme The value for the {@code scheme} attribute
* @param username The value for the {@code username} attribute
* @param password The value for the {@code password} attribute
* @param callTimeout The value for the {@code callTimeout} attribute
* @param connectTimeout The value for the {@code connectTimeout} attribute
* @param writeTimeout The value for the {@code writeTimeout} attribute
* @param readTimeout The value for the {@code readTimeout} attribute
* @param retries The value for the {@code retries} attribute
* @param delayBetweenAttempts The value for the {@code delayBetweenAttempts} attribute
* @param client The value for the {@code client} attribute
* @param scheduler The value for the {@code scheduler} attribute
* @param shutdownSchedulerOnClose The value for the {@code shutdownSchedulerOnClose} attribute
* @return An immutable Settings instance
*/
public static ImmutableSettings of(String host, int port, String scheme, @Nullable String username, @Nullable String password, Duration callTimeout, Duration connectTimeout, Duration writeTimeout, Duration readTimeout, int retries, Duration delayBetweenAttempts, OkHttpClient client, ScheduledExecutorService scheduler, boolean shutdownSchedulerOnClose) {
return new ImmutableSettings(host, port, scheme, username, password, callTimeout, connectTimeout, writeTimeout, readTimeout, retries, delayBetweenAttempts, client, scheduler, shutdownSchedulerOnClose);
}
/**
* Creates an immutable copy of a {@link KafkaConnectClient.Settings} value.
* Uses accessors to get values to initialize the new immutable instance.
* If an instance is already immutable, it is returned as is.
* @param instance The instance to copy
* @return A copied immutable Settings instance
*/
public static ImmutableSettings copyOf(KafkaConnectClient.Settings instance) {
if (instance instanceof ImmutableSettings) {
return (ImmutableSettings) instance;
}
return ImmutableSettings.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableSettings ImmutableSettings}.
*
* ImmutableSettings.builder()
* .host(String) // optional {@link KafkaConnectClient.Settings#host() host}
* .port(int) // optional {@link KafkaConnectClient.Settings#port() port}
* .scheme(String) // optional {@link KafkaConnectClient.Settings#scheme() scheme}
* .username(String | null) // nullable {@link KafkaConnectClient.Settings#username() username}
* .password(String | null) // nullable {@link KafkaConnectClient.Settings#password() password}
* .callTimeout(java.time.Duration) // optional {@link KafkaConnectClient.Settings#callTimeout() callTimeout}
* .connectTimeout(java.time.Duration) // optional {@link KafkaConnectClient.Settings#connectTimeout() connectTimeout}
* .writeTimeout(java.time.Duration) // optional {@link KafkaConnectClient.Settings#writeTimeout() writeTimeout}
* .readTimeout(java.time.Duration) // optional {@link KafkaConnectClient.Settings#readTimeout() readTimeout}
* .retries(int) // optional {@link KafkaConnectClient.Settings#retries() retries}
* .delayBetweenAttempts(java.time.Duration) // optional {@link KafkaConnectClient.Settings#delayBetweenAttempts() delayBetweenAttempts}
* .client(okhttp3.OkHttpClient) // optional {@link KafkaConnectClient.Settings#client() client}
* .scheduler(concurrent.ScheduledExecutorService) // optional {@link KafkaConnectClient.Settings#scheduler() scheduler}
* .shutdownSchedulerOnClose(boolean) // optional {@link KafkaConnectClient.Settings#shutdownSchedulerOnClose() shutdownSchedulerOnClose}
* .build();
*
* @return A new ImmutableSettings builder
*/
public static ImmutableSettings.Builder builder() {
return new ImmutableSettings.Builder();
}
/**
* Builds instances of type {@link ImmutableSettings ImmutableSettings}.
* Initialize attributes and then invoke the {@link #build()} method to create an
* immutable instance.
* {@code Builder} is not thread-safe and generally should not be stored in a field or collection,
* but instead used immediately to create instances.
*/
@Generated(from = "KafkaConnectClient.Settings", generator = "Immutables")
@NotThreadSafe
public static final class Builder implements KafkaConnectClient.Settings.Builder {
private static final long OPT_BIT_PORT = 0x1L;
private static final long OPT_BIT_USERNAME = 0x2L;
private static final long OPT_BIT_PASSWORD = 0x4L;
private static final long OPT_BIT_RETRIES = 0x8L;
private static final long OPT_BIT_SHUTDOWN_SCHEDULER_ON_CLOSE = 0x10L;
private long optBits;
private @Nullable String host;
private int port;
private @Nullable String scheme;
private @Nullable String username;
private @Nullable String password;
private @Nullable Duration callTimeout;
private @Nullable Duration connectTimeout;
private @Nullable Duration writeTimeout;
private @Nullable Duration readTimeout;
private int retries;
private @Nullable Duration delayBetweenAttempts;
private @Nullable OkHttpClient client;
private @Nullable ScheduledExecutorService scheduler;
private boolean shutdownSchedulerOnClose;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code com.github.jcustenborder.kafka.connect.client.AbstractSettings} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder from(AbstractSettings instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code com.github.jcustenborder.kafka.connect.client.KafkaConnectClient.Settings} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder from(KafkaConnectClient.Settings instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
private void from(Object object) {
if (object instanceof AbstractSettings) {
AbstractSettings instance = (AbstractSettings) object;
scheme(instance.scheme());
callTimeout(instance.callTimeout());
writeTimeout(instance.writeTimeout());
scheduler(instance.scheduler());
retries(instance.retries());
@Nullable String passwordValue = instance.password();
if (passwordValue != null) {
password(passwordValue);
}
delayBetweenAttempts(instance.delayBetweenAttempts());
port(instance.port());
readTimeout(instance.readTimeout());
host(instance.host());
connectTimeout(instance.connectTimeout());
client(instance.client());
shutdownSchedulerOnClose(instance.shutdownSchedulerOnClose());
@Nullable String usernameValue = instance.username();
if (usernameValue != null) {
username(usernameValue);
}
}
}
/**
* Initializes the value for the {@link KafkaConnectClient.Settings#host() host} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link KafkaConnectClient.Settings#host() host}.
* @param host The value for host
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder host(String host) {
this.host = Objects.requireNonNull(host, "host");
return this;
}
/**
* Initializes the value for the {@link KafkaConnectClient.Settings#port() port} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link KafkaConnectClient.Settings#port() port}.
* @param port The value for port
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder port(int port) {
this.port = port;
optBits |= OPT_BIT_PORT;
return this;
}
/**
* Initializes the value for the {@link KafkaConnectClient.Settings#scheme() scheme} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link KafkaConnectClient.Settings#scheme() scheme}.
* @param scheme The value for scheme
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder scheme(String scheme) {
this.scheme = Objects.requireNonNull(scheme, "scheme");
return this;
}
/**
* Initializes the value for the {@link KafkaConnectClient.Settings#username() username} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link KafkaConnectClient.Settings#username() username}.
* @param username The value for username (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder username(@Nullable String username) {
this.username = username;
optBits |= OPT_BIT_USERNAME;
return this;
}
/**
* Initializes the value for the {@link KafkaConnectClient.Settings#password() password} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link KafkaConnectClient.Settings#password() password}.
* @param password The value for password (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder password(@Nullable String password) {
this.password = password;
optBits |= OPT_BIT_PASSWORD;
return this;
}
/**
* Initializes the value for the {@link KafkaConnectClient.Settings#callTimeout() callTimeout} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link KafkaConnectClient.Settings#callTimeout() callTimeout}.
* @param callTimeout The value for callTimeout
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder callTimeout(Duration callTimeout) {
this.callTimeout = Objects.requireNonNull(callTimeout, "callTimeout");
return this;
}
/**
* Initializes the value for the {@link KafkaConnectClient.Settings#connectTimeout() connectTimeout} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link KafkaConnectClient.Settings#connectTimeout() connectTimeout}.
* @param connectTimeout The value for connectTimeout
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder connectTimeout(Duration connectTimeout) {
this.connectTimeout = Objects.requireNonNull(connectTimeout, "connectTimeout");
return this;
}
/**
* Initializes the value for the {@link KafkaConnectClient.Settings#writeTimeout() writeTimeout} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link KafkaConnectClient.Settings#writeTimeout() writeTimeout}.
* @param writeTimeout The value for writeTimeout
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder writeTimeout(Duration writeTimeout) {
this.writeTimeout = Objects.requireNonNull(writeTimeout, "writeTimeout");
return this;
}
/**
* Initializes the value for the {@link KafkaConnectClient.Settings#readTimeout() readTimeout} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link KafkaConnectClient.Settings#readTimeout() readTimeout}.
* @param readTimeout The value for readTimeout
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder readTimeout(Duration readTimeout) {
this.readTimeout = Objects.requireNonNull(readTimeout, "readTimeout");
return this;
}
/**
* Initializes the value for the {@link KafkaConnectClient.Settings#retries() retries} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link KafkaConnectClient.Settings#retries() retries}.
* @param retries The value for retries
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder retries(int retries) {
this.retries = retries;
optBits |= OPT_BIT_RETRIES;
return this;
}
/**
* Initializes the value for the {@link KafkaConnectClient.Settings#delayBetweenAttempts() delayBetweenAttempts} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link KafkaConnectClient.Settings#delayBetweenAttempts() delayBetweenAttempts}.
* @param delayBetweenAttempts The value for delayBetweenAttempts
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder delayBetweenAttempts(Duration delayBetweenAttempts) {
this.delayBetweenAttempts = Objects.requireNonNull(delayBetweenAttempts, "delayBetweenAttempts");
return this;
}
/**
* Initializes the value for the {@link KafkaConnectClient.Settings#client() client} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link KafkaConnectClient.Settings#client() client}.
* @param client The value for client
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder client(OkHttpClient client) {
this.client = Objects.requireNonNull(client, "client");
return this;
}
/**
* Initializes the value for the {@link KafkaConnectClient.Settings#scheduler() scheduler} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link KafkaConnectClient.Settings#scheduler() scheduler}.
* @param scheduler The value for scheduler
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder scheduler(ScheduledExecutorService scheduler) {
this.scheduler = Objects.requireNonNull(scheduler, "scheduler");
return this;
}
/**
* Initializes the value for the {@link KafkaConnectClient.Settings#shutdownSchedulerOnClose() shutdownSchedulerOnClose} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link KafkaConnectClient.Settings#shutdownSchedulerOnClose() shutdownSchedulerOnClose}.
* @param shutdownSchedulerOnClose The value for shutdownSchedulerOnClose
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder shutdownSchedulerOnClose(boolean shutdownSchedulerOnClose) {
this.shutdownSchedulerOnClose = shutdownSchedulerOnClose;
optBits |= OPT_BIT_SHUTDOWN_SCHEDULER_ON_CLOSE;
return this;
}
/**
* Builds a new {@link ImmutableSettings ImmutableSettings}.
* @return An immutable instance of Settings
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableSettings build() {
return new ImmutableSettings(this);
}
private boolean portIsSet() {
return (optBits & OPT_BIT_PORT) != 0;
}
private boolean usernameIsSet() {
return (optBits & OPT_BIT_USERNAME) != 0;
}
private boolean passwordIsSet() {
return (optBits & OPT_BIT_PASSWORD) != 0;
}
private boolean retriesIsSet() {
return (optBits & OPT_BIT_RETRIES) != 0;
}
private boolean shutdownSchedulerOnCloseIsSet() {
return (optBits & OPT_BIT_SHUTDOWN_SCHEDULER_ON_CLOSE) != 0;
}
}
}