be.looorent.ponto.client.http.PageUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ponto-client Show documentation
Show all versions of ponto-client Show documentation
Client library for Ponto (https://myponto.com)
The newest version!
package be.looorent.ponto.client.http;
import be.looorent.ponto.client.Page;
import lombok.var;
import java.util.ArrayList;
import java.util.Collection;
class PageUtil {
static String toQueryString(Page page) {
var array = toQueryArray(page);
if (array.isEmpty()) {
return "";
} else {
return "?"+ String.join("&", array);
}
}
private static Collection toQueryArray(Page page) {
var query = new ArrayList();
if (page != null) {
if (page.hasLimit()) {
query.add("limit="+page.getLimit());
}
if (page.hasBefore()) {
query.add("before="+page.getBefore());
}
if (page.hasAfter()) {
query.add("after="+page.getAfter());
}
}
return query;
}
}