tdlib-session-container/src/main/java/it/tdlight/reactiveapi/DiskSession.java
2021-12-05 23:47:54 +01:00

31 lines
828 B
Java

package it.tdlight.reactiveapi;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.jetbrains.annotations.Nullable;
@JsonInclude(Include.NON_NULL)
public class DiskSession {
@Nullable
public String token;
@Nullable
public Long phoneNumber;
@JsonCreator
public DiskSession(@JsonProperty("token") @Nullable String token,
@JsonProperty("phoneNumber") @Nullable Long phoneNumber) {
this.token = token;
this.phoneNumber = phoneNumber;
this.validate();
}
public void validate() {
if ((token == null) == (phoneNumber == null)) {
throw new UnsupportedOperationException("You must set either a token or a phone number");
}
}
}