pl.grzeslowski.jsupla.protocol.api.structs.sc.OAuthToken Maven / Gradle / Ivy
package pl.grzeslowski.jsupla.protocol.api.structs.sc;
import pl.grzeslowski.jsupla.protocol.api.structs.*;
import pl.grzeslowski.jsupla.protocol.api.types.ProtoWithSize;
import static pl.grzeslowski.jsupla.protocol.api.JavaConsts.*;
import static pl.grzeslowski.jsupla.protocol.api.Preconditions.*;
import static pl.grzeslowski.jsupla.protocol.api.consts.ProtoConsts.*;
/**
Original code:
typedef struct {
unsigned _supla_int_t ExpiresIn;
unsigned _supla_int_t
TokenSize; // including the terminating null byte ('\0')
char Token[SUPLA_OAUTH_TOKEN_MAXSIZE]; // Last variable in struct!
} TSC_OAuthToken;
*/
@lombok.EqualsAndHashCode @lombok.ToString
@javax.annotation.Generated(value="Struct original name: TSC_OAuthToken", date = "2024-08-03T11:49:42.266Z[Etc/UTC]")
public class OAuthToken implements pl.grzeslowski.jsupla.protocol.api.structs.sc.ServerClient {
/**
* unsigned int
*/
public final long expiresIn;
/**
* including the terminating null byte ('\0')
*
* unsigned int
*/
public final long tokenSize;
/**
* Last variable in struct!
*/
public final byte[] token;
public OAuthToken(long expiresIn,
long tokenSize,
byte[] token) {
this.expiresIn = unsigned(expiresIn);
this.tokenSize = sizeMax(unsigned(tokenSize), SUPLA_OAUTH_TOKEN_MAXSIZE);
this.token = checkArrayLength(token, (int) tokenSize);
}
@Override
public pl.grzeslowski.jsupla.protocol.api.calltypes.ServerClientCallType callType() {
throw new UnsupportedOperationException("CallType for " +getClass().getSimpleName()+" is not set!");
}
@Override
public int size() {
return INT_SIZE // expiresIn
+ INT_SIZE // tokenSize
+ (int) tokenSize * BYTE_SIZE // token
;
}
}