393 lines
11 KiB
Java
393 lines
11 KiB
Java
package ru.mtusi.messenger.dto;
|
|
|
|
import java.util.Objects;
|
|
import java.time.Instant;
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
|
import com.fasterxml.jackson.annotation.JsonValue;
|
|
import java.util.UUID;
|
|
import jakarta.validation.Valid;
|
|
import jakarta.validation.constraints.*;
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
|
import java.util.*;
|
|
import jakarta.annotation.Generated;
|
|
|
|
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.10.0")
|
|
public class AttachmentDTO {
|
|
|
|
private UUID id;
|
|
|
|
private UUID chatId;
|
|
|
|
private UUID ownerId;
|
|
|
|
private String filename;
|
|
|
|
/**
|
|
* Gets or Sets contentType
|
|
*/
|
|
public enum ContentTypeEnum {
|
|
IMAGE_PNG("image/png"),
|
|
IMAGE_JPEG("image/jpeg");
|
|
|
|
private final String value;
|
|
|
|
ContentTypeEnum(String value) {
|
|
this.value = value;
|
|
}
|
|
|
|
@JsonValue
|
|
public String getValue() {
|
|
return value;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return String.valueOf(value);
|
|
}
|
|
|
|
@JsonCreator
|
|
public static ContentTypeEnum fromValue(String value) {
|
|
for (ContentTypeEnum b : ContentTypeEnum.values()) {
|
|
if (b.value.equals(value)) {
|
|
return b;
|
|
}
|
|
}
|
|
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
|
}
|
|
}
|
|
|
|
private ContentTypeEnum contentType;
|
|
|
|
private Long sizeBytes;
|
|
|
|
private String sha256;
|
|
|
|
/**
|
|
* Gets or Sets status
|
|
*/
|
|
public enum StatusEnum {
|
|
READY("ready");
|
|
|
|
private final String value;
|
|
|
|
StatusEnum(String value) {
|
|
this.value = value;
|
|
}
|
|
|
|
@JsonValue
|
|
public String getValue() {
|
|
return value;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return String.valueOf(value);
|
|
}
|
|
|
|
@JsonCreator
|
|
public static StatusEnum fromValue(String value) {
|
|
for (StatusEnum b : StatusEnum.values()) {
|
|
if (b.value.equals(value)) {
|
|
return b;
|
|
}
|
|
}
|
|
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
|
}
|
|
}
|
|
|
|
private StatusEnum status;
|
|
|
|
@Valid
|
|
private List<@Valid VariantDTO> variants = new ArrayList<>();
|
|
|
|
private String errorCode;
|
|
|
|
private Instant createdAt;
|
|
|
|
private Instant updatedAt;
|
|
|
|
public AttachmentDTO() {
|
|
super();
|
|
}
|
|
|
|
/**
|
|
* Constructor with only required parameters
|
|
*/
|
|
public AttachmentDTO(UUID id, UUID chatId, UUID ownerId, String filename,
|
|
ContentTypeEnum contentType, Long sizeBytes, String sha256,
|
|
StatusEnum status, List<@Valid VariantDTO> variants,
|
|
String errorCode, Instant createdAt, Instant updatedAt) {
|
|
this.id = id;
|
|
this.chatId = chatId;
|
|
this.ownerId = ownerId;
|
|
this.filename = filename;
|
|
this.contentType = contentType;
|
|
this.sizeBytes = sizeBytes;
|
|
this.sha256 = sha256;
|
|
this.status = status;
|
|
this.variants = variants;
|
|
this.errorCode = errorCode;
|
|
this.createdAt = createdAt;
|
|
this.updatedAt = updatedAt;
|
|
}
|
|
|
|
public AttachmentDTO id(UUID id) {
|
|
this.id = id;
|
|
return this;
|
|
}
|
|
|
|
@Valid
|
|
@Schema(name = "id", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@JsonProperty("id")
|
|
public UUID getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(UUID id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public AttachmentDTO chatId(UUID chatId) {
|
|
this.chatId = chatId;
|
|
return this;
|
|
}
|
|
|
|
@Valid
|
|
@Schema(name = "chat_id", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@JsonProperty("chat_id")
|
|
public UUID getChatId() {
|
|
return chatId;
|
|
}
|
|
|
|
public void setChatId(UUID chatId) {
|
|
this.chatId = chatId;
|
|
}
|
|
|
|
public AttachmentDTO ownerId(UUID ownerId) {
|
|
this.ownerId = ownerId;
|
|
return this;
|
|
}
|
|
|
|
@Valid
|
|
@Schema(name = "owner_id", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@JsonProperty("owner_id")
|
|
public UUID getOwnerId() {
|
|
return ownerId;
|
|
}
|
|
|
|
public void setOwnerId(UUID ownerId) {
|
|
this.ownerId = ownerId;
|
|
}
|
|
|
|
public AttachmentDTO filename(String filename) {
|
|
this.filename = filename;
|
|
return this;
|
|
}
|
|
|
|
@NotNull
|
|
@Size(min = 1, max = 255)
|
|
@Schema(name = "filename", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@JsonProperty("filename")
|
|
public String getFilename() {
|
|
return filename;
|
|
}
|
|
|
|
public void setFilename(String filename) {
|
|
this.filename = filename;
|
|
}
|
|
|
|
public AttachmentDTO contentType(ContentTypeEnum contentType) {
|
|
this.contentType = contentType;
|
|
return this;
|
|
}
|
|
|
|
@NotNull
|
|
@Schema(name = "content_type", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@JsonProperty("content_type")
|
|
public ContentTypeEnum getContentType() {
|
|
return contentType;
|
|
}
|
|
|
|
public void setContentType(ContentTypeEnum contentType) {
|
|
this.contentType = contentType;
|
|
}
|
|
|
|
public AttachmentDTO sizeBytes(Long sizeBytes) {
|
|
this.sizeBytes = sizeBytes;
|
|
return this;
|
|
}
|
|
|
|
@NotNull
|
|
@Min(1L) @Max(10485760L)
|
|
@Schema(name = "size_bytes", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@JsonProperty("size_bytes")
|
|
public Long getSizeBytes() {
|
|
return sizeBytes;
|
|
}
|
|
|
|
public void setSizeBytes(Long sizeBytes) {
|
|
this.sizeBytes = sizeBytes;
|
|
}
|
|
|
|
public AttachmentDTO sha256(String sha256) {
|
|
this.sha256 = sha256;
|
|
return this;
|
|
}
|
|
|
|
@NotNull
|
|
@Pattern(regexp = "^[a-f0-9]{64}$")
|
|
@Schema(name = "sha256", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@JsonProperty("sha256")
|
|
public String getSha256() {
|
|
return sha256;
|
|
}
|
|
|
|
public void setSha256(String sha256) {
|
|
this.sha256 = sha256;
|
|
}
|
|
|
|
public AttachmentDTO status(StatusEnum status) {
|
|
this.status = status;
|
|
return this;
|
|
}
|
|
|
|
@NotNull
|
|
@Schema(name = "status", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@JsonProperty("status")
|
|
public StatusEnum getStatus() {
|
|
return status;
|
|
}
|
|
|
|
public void setStatus(StatusEnum status) {
|
|
this.status = status;
|
|
}
|
|
|
|
public AttachmentDTO variants(List<@Valid VariantDTO> variants) {
|
|
this.variants = variants;
|
|
return this;
|
|
}
|
|
|
|
public AttachmentDTO addVariantsItem(VariantDTO variantsItem) {
|
|
if (this.variants == null) {
|
|
this.variants = new ArrayList<>();
|
|
}
|
|
this.variants.add(variantsItem);
|
|
return this;
|
|
}
|
|
|
|
@NotNull @Valid
|
|
@Schema(name = "variants", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@JsonProperty("variants")
|
|
public List<@Valid VariantDTO> getVariants() {
|
|
return variants;
|
|
}
|
|
|
|
public void setVariants(List<@Valid VariantDTO> variants) {
|
|
this.variants = variants;
|
|
}
|
|
|
|
public AttachmentDTO errorCode(String errorCode) {
|
|
this.errorCode = errorCode;
|
|
return this;
|
|
}
|
|
|
|
@Schema(name = "error_code", requiredMode = Schema.RequiredMode.REQUIRED, nullable = true)
|
|
@JsonProperty("error_code")
|
|
public String getErrorCode() {
|
|
return errorCode;
|
|
}
|
|
|
|
public void setErrorCode(String errorCode) {
|
|
this.errorCode = errorCode;
|
|
}
|
|
|
|
public AttachmentDTO createdAt(Instant createdAt) {
|
|
this.createdAt = createdAt;
|
|
return this;
|
|
}
|
|
|
|
@NotNull
|
|
@Schema(name = "created_at", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@JsonProperty("created_at")
|
|
public Instant getCreatedAt() {
|
|
return createdAt;
|
|
}
|
|
|
|
public void setCreatedAt(Instant createdAt) {
|
|
this.createdAt = createdAt;
|
|
}
|
|
|
|
public AttachmentDTO updatedAt(Instant updatedAt) {
|
|
this.updatedAt = updatedAt;
|
|
return this;
|
|
}
|
|
|
|
@NotNull
|
|
@Schema(name = "updated_at", requiredMode = Schema.RequiredMode.REQUIRED)
|
|
@JsonProperty("updated_at")
|
|
public Instant getUpdatedAt() {
|
|
return updatedAt;
|
|
}
|
|
|
|
public void setUpdatedAt(Instant updatedAt) {
|
|
this.updatedAt = updatedAt;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (this == o) {
|
|
return true;
|
|
}
|
|
if (o == null || getClass() != o.getClass()) {
|
|
return false;
|
|
}
|
|
AttachmentDTO attachment = (AttachmentDTO) o;
|
|
return Objects.equals(this.id, attachment.id) &&
|
|
Objects.equals(this.chatId, attachment.chatId) &&
|
|
Objects.equals(this.ownerId, attachment.ownerId) &&
|
|
Objects.equals(this.filename, attachment.filename) &&
|
|
Objects.equals(this.contentType, attachment.contentType) &&
|
|
Objects.equals(this.sizeBytes, attachment.sizeBytes) &&
|
|
Objects.equals(this.sha256, attachment.sha256) &&
|
|
Objects.equals(this.status, attachment.status) &&
|
|
Objects.equals(this.variants, attachment.variants) &&
|
|
Objects.equals(this.errorCode, attachment.errorCode) &&
|
|
Objects.equals(this.createdAt, attachment.createdAt) &&
|
|
Objects.equals(this.updatedAt, attachment.updatedAt);
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return Objects.hash(id, chatId, ownerId, filename, contentType, sizeBytes,
|
|
sha256, status, variants, errorCode, createdAt, updatedAt);
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("class AttachmentDTO {\n");
|
|
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
|
sb.append(" chatId: ").append(toIndentedString(chatId)).append("\n");
|
|
sb.append(" ownerId: ").append(toIndentedString(ownerId)).append("\n");
|
|
sb.append(" filename: ").append(toIndentedString(filename)).append("\n");
|
|
sb.append(" contentType: ").append(toIndentedString(contentType)).append("\n");
|
|
sb.append(" sizeBytes: ").append(toIndentedString(sizeBytes)).append("\n");
|
|
sb.append(" sha256: ").append(toIndentedString(sha256)).append("\n");
|
|
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
|
sb.append(" variants: ").append(toIndentedString(variants)).append("\n");
|
|
sb.append(" errorCode: ").append(toIndentedString(errorCode)).append("\n");
|
|
sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n");
|
|
sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n");
|
|
sb.append("}");
|
|
return sb.toString();
|
|
}
|
|
|
|
private String toIndentedString(Object o) {
|
|
if (o == null) {
|
|
return "null";
|
|
}
|
|
return o.toString().replace("\n", "\n ");
|
|
}
|
|
} |