All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.mail.jira.plugins.commons.dto.DataListDTO Maven / Gradle / Ivy

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();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy