Interface Limit

All Known Implementing Classes:
Limit.Limited, Limit.Unlimited

public sealed interface Limit permits Limit.Limited, Limit.Unlimited
Limit represents the maximum value up to which an operation should continue processing. It may be used for defining the maximum number of results within a repository finder method or if applicable a template operation.

A isUnlimited() is used to indicate that there is no Limit defined, which should be favoured over using null or Optional.empty() to indicate the absence of an actual Limit.

Limit itself does not make assumptions about the actual max() value sign. This means that a negative value may be valid within a defined context.
Since:
3.2
Author:
Christoph Strobl
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
     
    static final class 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    default boolean
     
    int
    max()
     
    static Limit
    of(int max)
    Create a new Limit from the given max value.
    static Limit
     
  • Method Details

    • unlimited

      static Limit unlimited()
      Returns:
      a Limit instance that does not define max() and answers isUnlimited() with true.
    • of

      static Limit of(int max)
      Create a new Limit from the given max value.
      Parameters:
      max - the maximum value.
      Returns:
      new instance of Limit.
    • max

      int max()
      Returns:
      the max number of potential results.
    • isLimited

      boolean isLimited()
      Returns:
      true if limiting (maximum value) should be applied.
    • isUnlimited

      default boolean isUnlimited()
      Returns:
      true if no limiting (maximum value) should be applied.