Added object lists as per requirement

This commit is contained in:
Jim Martens 2020-07-11 19:33:28 +02:00
parent 8787784067
commit e2f896338f
3 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,32 @@
package de.twomartens.oparlservice.entity;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@Builder
@Getter
@ToString
@EqualsAndHashCode
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Links {
@Schema(description = "URL to the first list page", nullable = true)
private final String first;
@Schema(description = "URL to the previous list page", nullable = true)
private final String prev;
@Schema(description = "canonical URL for the current list page", nullable = true)
private final String self;
@Schema(description = "URL to the next list page", required = true)
private final String next;
@Schema(description = "URL to the last list page", nullable = true)
private final String last;
@Schema(description = "URL of a website that presents the object in the browser", nullable = true)
private String web;
}

View File

@ -0,0 +1,28 @@
package de.twomartens.oparlservice.entity;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.List;
@Builder
@Getter
@ToString
@EqualsAndHashCode
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ObjectList<T> {
@NonNull
@Schema(description = "contains list of objects", required = true)
private final List<T> data;
@NonNull
@Schema(description = "contains information about pagination", required = true)
private final Pagination pagination;
@NonNull
@Schema(description = "contains links related to this list", required = true)
private final Links links;
}

View File

@ -0,0 +1,26 @@
package de.twomartens.oparlservice.entity;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@Builder
@Getter
@ToString
@EqualsAndHashCode
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Pagination {
@Schema(description = "specifies total number of objects in the list", nullable = true)
private final int totalElements;
@Schema(description = "specifies the number of objects per list page", nullable = true)
private final int elementsPerPage;
@Schema(description = "specifies the current page number in the list", nullable = true)
private final int currentPage;
@Schema(description = "specifies the total number of pages in the list", nullable = true)
private final int totalPages;
}