Interface TopData<V>

All Superinterfaces:
Comparator<V>
All Known Implementing Classes:
ExpressionBasedTopData, GroupTopData, IndexedTopData, KingdomTopData, NationTopData, TopRPDonations

public interface TopData<V> extends Comparator<V>
Any database that can sort and provide data based on a comparator that it implements. They must implement two main functionalities:
  • Getting the position number of the data.
  • Getting the data at a given position in the leaderboard.
  • Getting all data from the leaderboard in order.
  • Method Summary

    Modifier and Type
    Method
    Description
    @IntRange(from=1L) Optional<Integer>
    It's possible for two different data to have the same position.
    @NotNull @Unmodifiable List<V>
    Gets all the top data in descending order that they should appear, starting from 1st position to last.
    @NotNull @Unmodifiable List<V>
    getTop(@org.checkerframework.common.value.qual.IntRange(from=0L) int skip, @org.checkerframework.common.value.qual.IntRange(from=1L) int limit, @Nullable Predicate<V> predicate)
    More performant version of getTop() for data pagination optimization support.
    getTopPosition(@org.checkerframework.common.value.qual.IntRange(from=1L) int position)
    Gets the data at the given position, or null if this data is not included.
    default boolean
    isIncluded(V data)
     
    @org.checkerframework.common.value.qual.IntRange(from=0L) int
    Gets the total size of data included in this leaderboard.
    void
    update(@NotNull @Unmodifiable Collection<V> allData)
    Update and override the top data with the provided new set of data.
  • Method Details

    • getTopPosition

      Optional<V> getTopPosition(@org.checkerframework.common.value.qual.IntRange(from=1L) int position)
      Gets the data at the given position, or null if this data is not included.
      Parameters:
      position - starting from 1.
    • getPositionOf

      @IntRange(from=1L) Optional<Integer> getPositionOf(@NotNull V data)
      It's possible for two different data to have the same position. This happens when the comparator implementation doesn't distinguish between them.
      Returns:
      The position of the data starting from 1. If the data is not cached, returns empty.
    • isIncluded

      default boolean isIncluded(V data)
      Returns:
      true if this data is included in the leaderboard, otherwise false.
    • getTop

      @NotNull @NotNull @Unmodifiable List<V> getTop(@org.checkerframework.common.value.qual.IntRange(from=0L) int skip, @org.checkerframework.common.value.qual.IntRange(from=1L) int limit, @Nullable @Nullable Predicate<V> predicate)
      More performant version of getTop() for data pagination optimization support.
      Parameters:
      skip - the amount of entries to skip.
      limit - the amount of entries to keep.
      predicate - the entries to skip.
      See Also:
    • getTop

      @NotNull @NotNull @Unmodifiable List<V> getTop()
      Gets all the top data in descending order that they should appear, starting from 1st position to last. First position being the data with the most "value".
      See Also:
    • size

      @org.checkerframework.common.value.qual.IntRange(from=0L) int size()
      Gets the total size of data included in this leaderboard.
    • update

      void update(@NotNull @NotNull @Unmodifiable Collection<V> allData)
      Update and override the top data with the provided new set of data.