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

com.jaregu.database.queries.ext.PageableSearch Maven / Gradle / Ivy

Go to download

Java based SQL templating project. Store your queries in *.sql files and build queries for execution. Supports simple expressions and conditional clauses and interface proxying for java-sql bridge.

There is a newer version: 1.4.1
Show newest version
package com.jaregu.database.queries.ext;

import com.jaregu.database.queries.dialect.Pageable;

public interface PageableSearch> extends Pageable {

	T withOffset(Integer offset);

	T withLimit(Integer limit);

	default T nextPage() {
		if (getLimit() != null && getOffset() != null) {
			return withOffset(getOffset() + getLimit());
		}
		throw new IllegalStateException("Limit or offset is null, can't go to next page!");
	}

	default T nextPageFull(int rowCount) {
		if (getLimit() != null && getOffset() != null) {
			if (getOffset() + getLimit() + getLimit() > rowCount) {
				return withOffset(rowCount > getLimit() ? rowCount - getLimit() : 0);
			} else {
				return nextPage();
			}
		}
		throw new IllegalStateException("Limit or offset is null, can't go to next page!");
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy