Class Page

    • Field Detail

      • ALL

        public static final Page ALL
      • ONE

        public static final Page ONE
    • Constructor Detail

      • Page

        public Page​(Integer offset,
                    Integer limit,
                    LinkedHashMap<String,​Boolean> ordering,
                    Map<String,​Object> requiredCriteria,
                    Map<String,​Object> optionalCriteria)
        Creates a new Page. You can for convenience also use of(int, int) or the with() builder.
        Parameters:
        offset - Zero-based offset of the page. May not be negative. Defaults to 0.
        limit - Maximum amount of records to be matched. May not be less than 1. Defaults to Integer.MAX_VALUE.
        ordering - Ordering of results. Map key represents property path and map value represents whether to sort ascending. Defaults to {"id",false}.
        requiredCriteria - Required criteria. Map key represents property path and map value represents criteria. Each entity must match all of given criteria.
        optionalCriteria - Optional criteria. Map key represents property path and map value represents criteria. Each entity must match at least one of given criteria.
      • Page

        public Page​(Integer offset,
                    Integer limit,
                    Identifiable<?> last,
                    Boolean reversed,
                    LinkedHashMap<String,​Boolean> ordering,
                    Map<String,​Object> requiredCriteria,
                    Map<String,​Object> optionalCriteria)
        Creates a new Page whereby value based paging will be performed instead of offset based paging when applicable. Value based paging is not applicable when the result type is a DTO, or when the ordering contains an aggregated field.
        Parameters:
        offset - Zero-based offset of the page. May not be negative. Defaults to 0.
        limit - Maximum amount of records to be matched. May not be less than 1. Defaults to Integer.MAX_VALUE.
        last - Last entity of the previous page. When not null, then value based paging will be performed instead of offset based paging when applicable.
        reversed - Whether value based paging is reversed. This is ignored when last entity is null. Defaults to false.
        ordering - Ordering of results. Map key represents property path and map value represents whether to sort ascending. Defaults to {"id",false}.
        requiredCriteria - Required criteria. Map key represents property path and map value represents criteria. Each entity must match all of given criteria.
        optionalCriteria - Optional criteria. Map key represents property path and map value represents criteria. Each entity must match at least one of given criteria.
    • Method Detail

      • getOffset

        public int getOffset()
        Returns the offset. Defaults to 0.
        Returns:
        The offset.
      • getLimit

        public int getLimit()
        Returns the limit. Defaults to Integer.MAX_VALUE.
        Returns:
        The limit.
      • getLast

        public Identifiable<?> getLast()
        Returns the last entity of the previous page, if any. If not null, then value based paging will be performed instead of offset based paging when applicable.
        Returns:
        The last entity of the previous page, if any.
      • isReversed

        public boolean isReversed()
        Returns whether the value based paging is reversed. This is only used when getLast() is not null.
        Returns:
        Whether the value based paging is reversed.
      • getOrdering

        public Map<String,​Boolean> getOrdering()
        Returns the ordering. Map key represents property path and map value represents whether to sort ascending. Defaults to {"id",false}.
        Returns:
        The ordering.
      • getRequiredCriteria

        public Map<String,​Object> getRequiredCriteria()
        Returns the required criteria. Map key represents property path and map value represents criteria. Each entity must match all of given criteria.
        Returns:
        The required criteria.
      • getOptionalCriteria

        public Map<String,​Object> getOptionalCriteria()
        Returns the optional criteria. Map key represents property path and map value represents criteria. Each entity must match at least one of given criteria.
        Returns:
        The optional criteria.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • all

        public Page all()
        Returns a clone of the current page which returns all results matching the current ordering, required criteria and optional criteria.
        Returns:
        A clone of the current page which returns all results matching the current ordering, required criteria and optional criteria.
      • with

        public static Page.Builder with()
        Use this if you want to build a new page.
        Returns:
        A new page builder.
      • of

        public static Page of​(int offset,
                              int limit)
        Use this if you want a page of given offset and limit.
        Parameters:
        offset - Zero-based offset of the page. May not be negative. Defaults to 0.
        limit - Maximum amount of records to be matched. May not be less than 1. Defaults to Integer.MAX_VALUE.
        Returns:
        A new page of given offset and limit.