io.sphere.sdk.queries.PagedQueryResult Maven / Gradle / Ivy
package io.sphere.sdk.queries;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
/**
* A container for query responses which contains a subset of the matching values.
* @param the type of the underlying model, like category or product.
*/
public class PagedQueryResult extends PagedResult {
@JsonCreator
PagedQueryResult(final Integer offset, final Integer total, final List results) {
super(offset, total, results);
}
/**
* Creates a {@code PagedQueryResult} for queries with no matching values.
* @param the type of the underlying model
* @return an empty {@code PagedQueryResult}
*/
public static PagedQueryResultDsl empty() {
return new PagedQueryResultDsl<>(0, 0, Collections.emptyList());
}
public static PagedQueryResultDsl of(final Integer offset, final Integer total, final List results) {
return new PagedQueryResultDsl<>(offset, total, results);
}
public static PagedQueryResultDsl of(final List results) {
return of(0, results.size(), results);
}
@JsonIgnore
public static PagedQueryResultDsl of(final T singleResult) {
return of(Collections.singletonList(singleResult));
}
@Override
public Integer getOffset() {
return super.getOffset();
}
@Override
public List getResults() {
return super.getResults();
}
@Override
public Integer getTotal() {
return super.getTotal();
}
@Override
public Optional head() {
return super.head();
}
@Override
public boolean isFirst() {
return super.isFirst();
}
@Override
public boolean isLast() {
return super.isLast();
}
@Override
public int size() {
return super.size();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy