io.prismic.Response Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-kit Show documentation
Show all versions of java-kit Show documentation
The developer kit to access Prismic.io repositories using the Java language.
The newest version!
package io.prismic;
import com.fasterxml.jackson.databind.JsonNode;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class Response {
private final List results;
private final int page;
private final int results_per_page;
private final int total_results_size;
private final int total_pages;
private final String next_page;
private final String prev_page;
public Response(List results, int page, int results_per_page, int total_results_size, int total_pages, String next_page, String prev_page){
this.results = results;
this.page = page;
this.results_per_page = results_per_page;
this.total_results_size = total_results_size;
this.total_pages = total_pages;
this.next_page = next_page;
this.prev_page = prev_page;
}
public List getResults() {
return this.results;
}
public int getPage() {
return this.page;
}
public int getResultsPerPage() {
return this.results_per_page;
}
public int getTotalResultsSize() {
return this.total_results_size;
}
public int getTotalPages() {
return this.total_pages;
}
public String getNextPage() {
return this.next_page;
}
public String getPrevPage() {
return this.prev_page;
}
static Response parse(JsonNode json) {
Iterator resultsJson;
resultsJson = json.path("results").elements();
List results = new ArrayList<>();
while (resultsJson.hasNext()) {
results.add(Document.parse(resultsJson.next()));
}
return new Response(results,
Integer.parseInt(json.path("page").asText()),
Integer.parseInt(json.path("results_per_page").asText()),
Integer.parseInt(json.path("total_results_size").asText()),
Integer.parseInt(json.path("total_pages").asText()),
json.path("next_page").asText().equals("null") ? null : json.path("next_page").asText(),
json.path("prev_page").asText().equals("null") ? null : json.path("prev_page").asText()
);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy