return authentication data when possible

This commit is contained in:
Andrea Cavalli 2023-05-09 23:23:57 +02:00
parent 84228cfbf2
commit 706d7a5b09
4 changed files with 10 additions and 6 deletions

View File

@ -6,7 +6,7 @@ import java.util.Objects;
import java.util.concurrent.CompletableFuture;
@SuppressWarnings("unused")
final class AuthenticationDataImpl implements AuthenticationSupplier<AuthenticationDataImpl>, AuthenticationData {
final class AuthenticationDataImpl implements SimpleAuthenticationSupplier<AuthenticationDataImpl> {
private final String userPhoneNumber;
private final String botToken;

View File

@ -2,7 +2,7 @@ package it.tdlight.client;
import java.util.concurrent.CompletableFuture;
class AuthenticationDataQrCode implements AuthenticationSupplier<AuthenticationDataQrCode>, AuthenticationData {
class AuthenticationDataQrCode implements SimpleAuthenticationSupplier<AuthenticationDataQrCode> {
@Override
public boolean isQrCode() {

View File

@ -6,7 +6,7 @@ public interface AuthenticationSupplier<T extends AuthenticationData> {
CompletableFuture<T> get();
static AuthenticationSupplier<?> qrCode() {
static SimpleAuthenticationSupplier<?> qrCode() {
return new AuthenticationDataQrCode();
}
@ -14,15 +14,15 @@ public interface AuthenticationSupplier<T extends AuthenticationData> {
* Deprecated, use {@link #user(String)} instead
*/
@Deprecated
static AuthenticationSupplier<?> user(long userPhoneNumber) {
static SimpleAuthenticationSupplier<?> user(long userPhoneNumber) {
return user(String.valueOf(userPhoneNumber));
}
static AuthenticationSupplier<?> user(String userPhoneNumber) {
static SimpleAuthenticationSupplier<?> user(String userPhoneNumber) {
return new AuthenticationDataImpl(userPhoneNumber, null);
}
static AuthenticationSupplier<?> bot(String botToken) {
static SimpleAuthenticationSupplier<?> bot(String botToken) {
return new AuthenticationDataImpl(null, botToken);
}

View File

@ -0,0 +1,4 @@
package it.tdlight.client;
public interface SimpleAuthenticationSupplier<T extends AuthenticationData> extends AuthenticationSupplier<T>,
AuthenticationData {}