default lists to empty

This commit is contained in:
Jonathan Klabunde Tomer 2025-04-24 15:23:06 -07:00 committed by Chris Eager
parent 63c79173b2
commit 38befdb260
1 changed files with 15 additions and 0 deletions

View File

@ -5,11 +5,13 @@
package org.whispersystems.textsecuregcm.entities; package org.whispersystems.textsecuregcm.entities;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import java.util.List; import java.util.List;
public record SetKeysRequest( public record SetKeysRequest(
@NotNull
@Valid @Valid
@Size(max=100) @Size(max=100)
@Schema(description = """ @Schema(description = """
@ -27,6 +29,7 @@ public record SetKeysRequest(
""") """)
ECSignedPreKey signedPreKey, ECSignedPreKey signedPreKey,
@NotNull
@Valid @Valid
@Size(max=100) @Size(max=100)
@Schema(description = """ @Schema(description = """
@ -43,4 +46,16 @@ public record SetKeysRequest(
deleted. If present, must have a valid signature from the identity key in this request. deleted. If present, must have a valid signature from the identity key in this request.
""") """)
KEMSignedPreKey pqLastResortPreKey) { KEMSignedPreKey pqLastResortPreKey) {
public SetKeysRequest {
// Its a little counter-intuitive, but this compact constructor allows a default value
// to be used when one isnt specified, allowing the field to still be
// validated as @NotNull
if (preKeys == null) {
preKeys = List.of();
}
if (pqPreKeys == null) {
pqPreKeys = List.of();
}
}
} }