<commit_before>package py.una.med.base.util;

import java.io.Serializable;
import py.una.med.base.business.ISIGHBaseLogic;
import py.una.med.base.dao.restrictions.Where;
import py.una.med.base.dao.search.ISearchParam;
import py.una.med.base.dao.search.SearchParam;
import py.una.med.base.dao.util.EntityExample;

public class PagingHelper<T, ID extends Serializable> {

	private int rowsForPage = 10;
	private int page = 0;
	T example;
	private Long currentCount;
	private Long totalCount;

	public PagingHelper(int rowsForPage) {

		this.rowsForPage = rowsForPage;
	}

	public ISearchParam getISearchparam() {

		SearchParam sp = new SearchParam();
		sp.setOffset(page * rowsForPage);
		sp.setLimit(rowsForPage);
		return sp;
	}

	public void next() {

		// TODO controlar que al llegar a la última pagina se deshabilite el
		// boton siguiente

		if (page + 1 > getMaxPage(currentCount)) {
			return;
		}
		this.page++;
	}

	public void goMaxPage() {

		this.page = getMaxPage(currentCount) - 1;

	}

	public void goInitPage() {

		this.page = 0;
	}

	public void last() {

		// TODO controlar que al llegar a la primera pagina se deshabilite el
		// boton atras
		if (page > 0) {
			this.page--;
		}

	}

	public int getPage() {

		return page;
	}

	public void setPage(int page) {

		this.page = page;
	}

	public String getFormattedPage() {

		Long firstRecord = new Long(page * rowsForPage + 1);
		Long limit = new Long(page * rowsForPage + rowsForPage);

		if (page + 1 == getMaxPage(currentCount)) {
			limit = currentCount;
		}

		if (currentCount == 0) {
			limit = 0L;
			firstRecord = 0L;
		}
		String formattedPage = firstRecord + "-" + limit + " de "
				+ currentCount;

		return formattedPage;
	}

	private int getMaxPage(Long count) {

		// TODO cambiar la forma de redondear hacia arriba, usar ceil<commit_msg>Performance - Uso del valueOf<commit_after>package py.una.med.base.util;

import java.io.Serializable;
import py.una.med.base.business.ISIGHBaseLogic;
import py.una.med.base.dao.restrictions.Where;
import py.una.med.base.dao.search.ISearchParam;
import py.una.med.base.dao.search.SearchParam;
import py.una.med.base.dao.util.EntityExample;

public class PagingHelper<T, ID extends Serializable> {

	private int rowsForPage = 10;
	private int page = 0;
	T example;
	private Long currentCount;
	private Long totalCount;

	public PagingHelper(int rowsForPage) {

		this.rowsForPage = rowsForPage;
	}

	public ISearchParam getISearchparam() {

		SearchParam sp = new SearchParam();
		sp.setOffset(page * rowsForPage);
		sp.setLimit(rowsForPage);
		return sp;
	}

	public void next() {

		// TODO controlar que al llegar a la última pagina se deshabilite el
		// boton siguiente

		if (page + 1 > getMaxPage(currentCount)) {
			return;
		}
		this.page++;
	}

	public void goMaxPage() {

		this.page = getMaxPage(currentCount) - 1;

	}

	public void goInitPage() {

		this.page = 0;
	}

	public void last() {

		// TODO controlar que al llegar a la primera pagina se deshabilite el
		// boton atras
		if (page > 0) {
			this.page--;
		}

	}

	public int getPage() {

		return page;
	}

	public void setPage(int page) {

		this.page = page;
	}

	public String getFormattedPage() {

		Long firstRecord = Long.valueOf(page * rowsForPage + 1);
		Long limit = Long.valueOf(page * rowsForPage + rowsForPage);

		if (page + 1 == getMaxPage(currentCount)) {
			limit = currentCount;
		}

		if (currentCount == 0) {
			limit = 0L;
			firstRecord = 0L;
		}
		String formattedPage = firstRecord + "-" + limit + " de "
				+ currentCount;

		return formattedPage;
	}

	private int getMaxPage(Long count) {

		// TODO cambiar la forma de redondear hacia arriba, usar ceil
{'fraction_non_alphanumeric': 0.11114130434782608, 'fraction_numerical': 0.006521739130434782, 'mean_word_length': 3.392601431980907, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2647148', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1266, 'n_words': 338}