Package org.kingdoms.constants.top
Interface TopData<V>
- All Superinterfaces:
Comparator<V>
- All Known Implementing Classes:
ExpressionBasedTopData,GroupTopData,IndexedTopData,KingdomTopData,NationTopData,TopRPDonations
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 TypeMethodDescriptiongetPositionOf(V data) It's possible for two different data to have the same position.getTop()Gets all the top data in descending order that they should appear, starting from 1st position to last.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 ofgetTop()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 booleanisIncluded(V data) @org.checkerframework.common.value.qual.IntRange(from=0L) intsize()Gets the total size of data included in this leaderboard.voidupdate(@NotNull @Unmodifiable Collection<V> allData) Update and override the top data with the provided new set of data.Methods inherited from interface java.util.Comparator
compare, equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Method Details
-
getTopPosition
Gets the data at the given position, or null if this data is not included.- Parameters:
position- starting from 1.
-
getPositionOf
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
- 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 ofgetTop()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
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
Update and override the top data with the provided new set of data.
-