All Downloads are FREE. Search and download functionalities are using the official Maven repository.

devutility.internal.data.SearchUtils Maven / Gradle / Ivy

There is a newer version: 1.3.8.1
Show newest version
package devutility.internal.data;

import java.util.List;

import devutility.internal.models.BaseSearchParam;
import devutility.internal.util.CollectionUtils;
import devutility.internal.util.function.PredicateBuilder;

public class SearchUtils {
	public static  List search(List list, BaseSearchParam searchParam) {
		PredicateBuilder predicateBuilder = searchParam.getPredicateBuilder();

		if (!predicateBuilder.isHasPredicate()) {
			return list;
		}

		return CollectionUtils.parallelList(list, predicateBuilder.getPredicate());
	}

	/**
	 * Calculate pages count for given total count and page size.
	 * @param totalCount: Total records count.
	 * @param pageSize: Page size
	 * @return int
	 */
	public static int calculatePagesCount(int totalCount, int pageSize) {
		if (totalCount % pageSize == 0) {
			return totalCount / pageSize;
		}

		return totalCount / pageSize + 1;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy