Files
mtusi2026lab7/src/main/java/ru/mtusi/messenger/dto/MessagePageDTO.java
T

106 lines
2.8 KiB
Java

package ru.mtusi.messenger.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class MessagePageDTO {
@Valid private List<@Valid MessageDTO> items = new ArrayList<>();
private String nextCursor = null;
public MessagePageDTO() {
super();
}
public MessagePageDTO(List<@Valid MessageDTO> items, String nextCursor) {
this.items = items;
this.nextCursor = nextCursor;
}
public MessagePageDTO items(List<@Valid MessageDTO> items) {
this.items = items;
return this;
}
public MessagePageDTO addItemsItem(MessageDTO itemsItem) {
if (this.items == null) {
this.items = new ArrayList<>();
}
this.items.add(itemsItem);
return this;
}
@NotNull
@Valid
@Schema(name = "items", requiredMode = Schema.RequiredMode.REQUIRED)
@JsonProperty("items")
public List<@Valid MessageDTO> getItems() {
return items;
}
public void setItems(List<@Valid MessageDTO> items) {
this.items = items;
}
public MessagePageDTO nextCursor(String nextCursor) {
this.nextCursor = nextCursor;
return this;
}
@JsonInclude(JsonInclude.Include.ALWAYS)
@Schema(name = "next_cursor", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("next_cursor")
public String getNextCursor() {
return nextCursor;
}
public void setNextCursor(String nextCursor) {
this.nextCursor = nextCursor;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MessagePageDTO messagePageDTO = (MessagePageDTO) o;
return Objects.equals(this.items, messagePageDTO.items)
&& Objects.equals(this.nextCursor, messagePageDTO.nextCursor);
}
@Override
public int hashCode() {
return Objects.hash(items, nextCursor);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class MessagePageDTO {\n");
sb.append(" items: ").append(toIndentedString(items)).append("\n");
sb.append(" nextCursor: ").append(toIndentedString(nextCursor)).append("\n");
sb.append("}");
return sb.toString();
}
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}