From e2f896338f7ee16f4788d2482c485f134bc5757f Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Sat, 11 Jul 2020 19:33:28 +0200 Subject: [PATCH] Added object lists as per requirement --- .../twomartens/oparlservice/entity/Links.java | 32 +++++++++++++++++++ .../oparlservice/entity/ObjectList.java | 28 ++++++++++++++++ .../oparlservice/entity/Pagination.java | 26 +++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 oparl-server/src/main/java/de/twomartens/oparlservice/entity/Links.java create mode 100644 oparl-server/src/main/java/de/twomartens/oparlservice/entity/ObjectList.java create mode 100644 oparl-server/src/main/java/de/twomartens/oparlservice/entity/Pagination.java diff --git a/oparl-server/src/main/java/de/twomartens/oparlservice/entity/Links.java b/oparl-server/src/main/java/de/twomartens/oparlservice/entity/Links.java new file mode 100644 index 0000000..7c4fbda --- /dev/null +++ b/oparl-server/src/main/java/de/twomartens/oparlservice/entity/Links.java @@ -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; +} diff --git a/oparl-server/src/main/java/de/twomartens/oparlservice/entity/ObjectList.java b/oparl-server/src/main/java/de/twomartens/oparlservice/entity/ObjectList.java new file mode 100644 index 0000000..de6e50c --- /dev/null +++ b/oparl-server/src/main/java/de/twomartens/oparlservice/entity/ObjectList.java @@ -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 { + @NonNull + @Schema(description = "contains list of objects", required = true) + private final List 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; +} diff --git a/oparl-server/src/main/java/de/twomartens/oparlservice/entity/Pagination.java b/oparl-server/src/main/java/de/twomartens/oparlservice/entity/Pagination.java new file mode 100644 index 0000000..c9b1c28 --- /dev/null +++ b/oparl-server/src/main/java/de/twomartens/oparlservice/entity/Pagination.java @@ -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; +}