tdlib-session-container/src/main/java/it/tdlight/reactiveapi/InstanceSettings.java

59 lines
2.1 KiB
Java
Raw Normal View History

2021-12-05 15:15:28 +01:00
package it.tdlight.reactiveapi;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
2022-03-06 13:27:29 +01:00
import java.util.List;
2022-10-05 02:26:30 +02:00
import java.util.Objects;
2021-12-05 15:15:28 +01:00
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class InstanceSettings {
@NotNull
public String id;
2022-10-05 02:26:30 +02:00
public InstanceType instanceType;
2021-12-05 15:15:28 +01:00
/**
2022-10-05 02:26:30 +02:00
* If {@link #instanceType} is true, this will be the address of this client
2021-12-05 15:15:28 +01:00
*/
2022-10-05 02:26:30 +02:00
public @Nullable String listenAddress;
2021-12-05 15:15:28 +01:00
2022-01-09 18:27:14 +01:00
/**
2022-10-05 02:26:30 +02:00
* If {@link #instanceType} is false, this will transform resulting events <b>before</b> being sent
2022-01-09 18:27:14 +01:00
*/
2022-03-06 13:27:29 +01:00
public @Nullable List<Class<? extends ResultingEventTransformer>> resultingEventTransformers;
2022-01-09 18:27:14 +01:00
2022-10-05 02:26:30 +02:00
public InstanceSettings(@NotNull String id,
@NotNull InstanceType instanceType,
@Nullable String listenAddress,
@Nullable List<Class<? extends ResultingEventTransformer>> resultingEventTransformers) {
this.id = id;
this.instanceType = instanceType;
this.listenAddress = listenAddress;
this.resultingEventTransformers = resultingEventTransformers;
}
2021-12-05 15:15:28 +01:00
@JsonCreator
public InstanceSettings(@JsonProperty(required = true, value = "id") @NotNull String id,
2022-10-05 02:26:30 +02:00
@Deprecated @JsonProperty(value = "client", defaultValue = "null") Boolean deprecatedIsClient,
@JsonProperty(value = "instanceType", defaultValue = "null") String instanceType,
@Deprecated @JsonProperty(value = "clientAddress", defaultValue = "null") @Nullable String deprecatedClientAddress,
@JsonProperty(value = "listenAddress", defaultValue = "null") @Nullable String listenAddress,
@JsonProperty("resultingEventTransformers")
@Nullable List<Class<? extends ResultingEventTransformer>> resultingEventTransformers) {
2021-12-05 15:15:28 +01:00
this.id = id;
2022-10-05 02:26:30 +02:00
if (deprecatedIsClient != null) {
this.instanceType = deprecatedIsClient ? InstanceType.UPDATES_CONSUMER : InstanceType.TDLIB;
} else {
this.instanceType = InstanceType.valueOf(instanceType.toUpperCase());
}
if (deprecatedClientAddress != null) {
this.listenAddress = deprecatedClientAddress;
} else {
this.listenAddress = listenAddress;
}
2022-01-09 18:27:14 +01:00
this.resultingEventTransformers = resultingEventTransformers;
2021-12-05 15:15:28 +01:00
}
}