org.broadleafcommerce.core.search.domain.ProductSearchResult Maven / Gradle / Ivy
/*
* Copyright 2008-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.broadleafcommerce.core.search.domain;
import org.broadleafcommerce.core.catalog.domain.Product;
import java.util.List;
/**
* Container that holds the result of a ProductSearch
*
* @author Andre Azzolini (apazzolini)
*/
public class ProductSearchResult {
protected List products;
protected List facets;
protected Integer totalResults;
protected Integer page;
protected Integer pageSize;
public List getProducts() {
return products;
}
public void setProducts(List products) {
this.products = products;
}
public List getFacets() {
return facets;
}
public void setFacets(List facets) {
this.facets = facets;
}
public Integer getTotalResults() {
return totalResults;
}
public void setTotalResults(Integer totalResults) {
this.totalResults = totalResults;
}
public Integer getPage() {
return page;
}
public void setPage(Integer page) {
this.page = page;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public Integer getStartResult() {
return (products == null || products.size() == 0) ? 0 : ((page - 1) * pageSize) + 1;
}
public Integer getEndResult() {
return Math.min(page * pageSize, totalResults);
}
public Integer getTotalPages() {
return (products == null || products.size() == 0) ? 1 : (int) Math.ceil(totalResults * 1.0 / pageSize);
}
}