From 9c9bdf640650ef4108234551f2032c09cf427e1a Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Tue, 5 Apr 2016 12:20:49 +0200 Subject: [PATCH] fix json creator for PagedList for creating clients Signed-off-by: Michael Hirsch --- .../hawkbit/rest/resource/model/PagedList.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PagedList.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PagedList.java index 880ee0c16..757a6106e 100644 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PagedList.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PagedList.java @@ -14,9 +14,11 @@ import javax.validation.constraints.NotNull; import org.springframework.hateoas.ResourceSupport; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; /** * A list representation with meta data for pagination, e.g. containing the @@ -31,7 +33,9 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; @JsonInclude(Include.NON_NULL) public class PagedList extends ResourceSupport { + @JsonProperty private final List content; + @JsonProperty private final long totalElements; private final int size; @@ -41,14 +45,16 @@ public class PagedList extends ResourceSupport { * * @param content * the actual content of the list - * @param total + * @param totalElements * the total amount of elements * @throws NullPointerException * in case {@code content} is {@code null}. */ - public PagedList(@NotNull final List content, final long total) { + @JsonCreator + public PagedList(@JsonProperty("content") @NotNull final List content, + @JsonProperty("totalElements") final long totalElements) { this.size = content.size(); - this.totalElements = total; + this.totalElements = totalElements; this.content = content; }