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

org.jobrunr.storage.Paging Maven / Gradle / Ivy

Go to download

An easy way to perform background processing on the JVM. Backed by persistent storage. Open and free for commercial use.

There is a newer version: 7.4.1
Show newest version
package org.jobrunr.storage;

import org.jobrunr.storage.navigation.AmountRequest;
import org.jobrunr.storage.navigation.OffsetBasedPageRequest;

public class Paging {

    private Paging() {
    } // for sonarqube

    public static class AmountBasedList {
        public static AmountRequest ascOnUpdatedAt(int amount) {
            return new AmountRequest(StorageProviderUtils.Jobs.FIELD_UPDATED_AT + ":ASC", amount);
        }

        public static AmountRequest descOnUpdatedAt(int amount) {
            return new AmountRequest(StorageProviderUtils.Jobs.FIELD_UPDATED_AT + ":DESC", amount);
        }

        public static AmountRequest ascOnCreatedAt(int amount) {
            return new AmountRequest(StorageProviderUtils.Jobs.FIELD_CREATED_AT + ":ASC", amount);
        }
    }

    public static class OffsetBasedPage {

        public static OffsetBasedPageRequest next(Page page) {
            return OffsetBasedPageRequest.fromString(page.getNextPage());
        }

        public static OffsetBasedPageRequest previous(Page page) {
            return OffsetBasedPageRequest.fromString(page.getPreviousPage());
        }

        public static OffsetBasedPageRequest ascOnUpdatedAt(int amount) {
            return ascOnUpdatedAt(0, amount);
        }

        public static OffsetBasedPageRequest ascOnUpdatedAt(int offset, int amount) {
            return new OffsetBasedPageRequest(StorageProviderUtils.Jobs.FIELD_UPDATED_AT + ":ASC", offset, amount);
        }

        public static OffsetBasedPageRequest descOnUpdatedAt(int amount) {
            return descOnUpdatedAt(0, amount);
        }

        public static OffsetBasedPageRequest descOnUpdatedAt(int offset, int amount) {
            return new OffsetBasedPageRequest(StorageProviderUtils.Jobs.FIELD_UPDATED_AT + ":DESC", offset, amount);
        }

        public static OffsetBasedPageRequest ascOnScheduledAt(int amount) {
            return ascOnScheduledAt(0, amount);
        }

        public static OffsetBasedPageRequest ascOnScheduledAt(int offset, int amount) {
            return new OffsetBasedPageRequest(StorageProviderUtils.Jobs.FIELD_SCHEDULED_AT + ":ASC", offset, amount);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy