This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…116)
- Loading branch information
1 parent
804ff8d
commit 491eb37
Showing
8 changed files
with
87 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...rc/main/java/com/cerner/beadledom/client/example/model/JsonOneOffsetPaginatedListDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 0 additions & 59 deletions
59
...e-api/src/main/java/com/cerner/beadledom/client/example/model/OffsetPaginatedListDto.java
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
pagination/src/main/java/com/cerner/beadledom/pagination/OffsetPaginatedListDtoImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.cerner.beadledom.pagination; | ||
|
||
import com.cerner.beadledom.pagination.models.OffsetPaginatedListDto; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; | ||
import com.google.auto.value.AutoValue; | ||
import java.util.ArrayList; | ||
|
||
/** | ||
* Offset based pagination list. | ||
* | ||
* <p>Represents an offset based paginated list in a rest response. | ||
* | ||
* @author John Leacox | ||
* @since 3.2 | ||
*/ | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@AutoValue | ||
@JsonPropertyOrder({ | ||
"items", | ||
"totalResults", | ||
"firstLink", | ||
"lastLink", | ||
"nextLink", | ||
"prevLink" | ||
}) | ||
@JsonDeserialize(builder = OffsetPaginatedListDtoImpl.Builder.class) | ||
abstract class OffsetPaginatedListDtoImpl<T> implements OffsetPaginatedListDto<T> { | ||
|
||
/** | ||
* Creates a builder for {@link OffsetPaginatedListDtoImpl}. | ||
* | ||
* @return instance of {@link Builder} | ||
*/ | ||
public static <T> Builder<T> builder() { | ||
return new AutoValue_OffsetPaginatedListDtoImpl.Builder<T>() | ||
.items(new ArrayList<>()); | ||
} | ||
|
||
@AutoValue.Builder | ||
@JsonPOJOBuilder(withPrefix = "") | ||
public abstract static class Builder<T> implements OffsetPaginatedListDto.Builder<Builder<T>, T> { | ||
@JsonCreator | ||
private static OffsetPaginatedListDtoImpl.Builder create() { | ||
return OffsetPaginatedListDtoImpl.builder(); | ||
} | ||
|
||
public abstract OffsetPaginatedListDtoImpl<T> build(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 22 additions & 58 deletions
80
pagination/src/main/java/com/cerner/beadledom/pagination/models/OffsetPaginatedListDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,61 @@ | ||
package com.cerner.beadledom.pagination.models; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.cerner.beadledom.pagination.OffsetPaginatedList; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; | ||
import com.google.auto.value.AutoValue; | ||
import com.wordnik.swagger.annotations.ApiModelProperty; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* Offset based pagination list. | ||
* | ||
* <p>Represents an offset based paginated list in a rest response. | ||
* | ||
* @author John Leacox | ||
* @since 3.1 | ||
* <p>Represents an offset based paginated list in a rest response. Is used on the client side | ||
* instead of {@link OffsetPaginatedList} to circumvent type erasure. | ||
*/ | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@AutoValue | ||
@JsonPropertyOrder({ | ||
"items", | ||
"totalResults", | ||
"firstLink", | ||
"lastLink", | ||
"nextLink", | ||
"prevLink" | ||
}) | ||
@JsonDeserialize(builder = OffsetPaginatedListDto.Builder.class) | ||
public abstract class OffsetPaginatedListDto<T> { | ||
@JsonProperty("items") | ||
@ApiModelProperty(value = "Array of items for the current page") | ||
public abstract List<T> items(); | ||
public interface OffsetPaginatedListDto<T> { | ||
|
||
@Nullable | ||
@JsonProperty("totalResults") | ||
@ApiModelProperty(value = "Total count of items across all pages") | ||
public abstract Long totalResults(); | ||
@Nullable | ||
Long totalResults(); | ||
|
||
@JsonProperty("firstLink") | ||
public abstract String firstLink(); | ||
String firstLink(); | ||
|
||
@JsonProperty("lastLink") | ||
@Nullable | ||
public abstract String lastLink(); | ||
String lastLink(); | ||
|
||
@JsonProperty("prevLink") | ||
@Nullable | ||
public abstract String prevLink(); | ||
String prevLink(); | ||
|
||
@JsonProperty("nextLink") | ||
@Nullable | ||
public abstract String nextLink(); | ||
|
||
/** | ||
* Creates a builder for {@link OffsetPaginatedListDto}. | ||
* | ||
* @return instance of {@link Builder} | ||
*/ | ||
public static <T> Builder<T> builder() { | ||
return new AutoValue_OffsetPaginatedListDto.Builder<T>() | ||
.items(new ArrayList<>()); | ||
} | ||
String nextLink(); | ||
|
||
@JsonProperty("items") | ||
List<T> items(); | ||
|
||
@AutoValue.Builder | ||
@JsonPOJOBuilder(withPrefix = "") | ||
public abstract static class Builder<T> { | ||
@JsonCreator | ||
private static OffsetPaginatedListDto.Builder create() { | ||
return OffsetPaginatedListDto.builder(); | ||
} | ||
interface Builder<B extends Builder<B, T>, T> { | ||
|
||
@JsonProperty("items") | ||
public abstract Builder<T> items(List<T> items); | ||
B items(List<T> items); | ||
|
||
@JsonProperty("totalResults") | ||
public abstract Builder<T> totalResults(Long totalResults); | ||
B totalResults(Long totalResults); | ||
|
||
@JsonProperty("firstLink") | ||
public abstract Builder<T> firstLink(String firstLink); | ||
B firstLink(String firstLink); | ||
|
||
@JsonProperty("lastLink") | ||
public abstract Builder<T> lastLink(String lastLink); | ||
B lastLink(String lastLink); | ||
|
||
@JsonProperty("nextLink") | ||
public abstract Builder<T> nextLink(String nextLink); | ||
B nextLink(String nextLink); | ||
|
||
@JsonProperty("prevLink") | ||
public abstract Builder<T> prevLink(String prevLink); | ||
B prevLink(String prevLink); | ||
|
||
public abstract OffsetPaginatedListDto<T> build(); | ||
OffsetPaginatedListDto<T> build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters