ru.mail.jira.plugins.commons.dto.DataListDTO Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons Show documentation
Show all versions of commons Show documentation
Commons library for atlascommunity Jira plugins
The newest version!
package ru.mail.jira.plugins.commons.dto;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.time.Instant;
import java.util.Collection;
import java.util.Collections;
@Getter
@Setter
@Builder
@XmlRootElement
public class DataListDTO {
@NotNull @XmlElement private Collection data;
@XmlElement private int total;
@Nullable @XmlElement private Instant validUntil;
@NotNull
public static DataListDTO empty() {
return DataListDTO.builder().data(Collections.emptyList()).total(0).build();
}
@NotNull
public static DataListDTO just(@NotNull Collection data) {
return DataListDTO.builder().data(data).total(data.size()).build();
}
@NotNull
public static DataListDTO just(@NotNull Collection data, int total) {
return DataListDTO.builder().data(data).total(total).build();
}
}