Class IndexedTopData<K,V>

java.lang.Object
org.kingdoms.constants.top.IndexedTopData<K,V>
All Implemented Interfaces:
Comparator<V>, TopData<V>
Direct Known Subclasses:
ExpressionBasedTopData, TopRPDonations

public abstract class IndexedTopData<K,V> extends Object implements TopData<V>
The main top data implementation which uses a IndexedHashMap
  • Constructor Details

    • IndexedTopData

      public IndexedTopData()
  • Method Details

    • getTopPosition

      public Optional<V> getTopPosition(int position)
      Description copied from interface: TopData
      Gets the data at the given position, or null if this data is not included.
      Specified by:
      getTopPosition in interface TopData<K>
      Parameters:
      position - starting from 1.
    • getPositionOf

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

      public List<V> getTop(int skip, int limit, Predicate<V> predicate)
      Description copied from interface: TopData
      More performant version of TopData.getTop() for data pagination optimization support.
      Specified by:
      getTop in interface TopData<K>
      Parameters:
      skip - the amount of entries to skip.
      limit - the amount of entries to keep.
      predicate - the entries to skip.
      See Also:
    • update

      @Internal public void update(Collection<V> allData)
      Description copied from interface: TopData
      Update and override the top data with the provided new set of data.
      Specified by:
      update in interface TopData<K>
    • getTop

      @NotNull public @NotNull @Unmodifiable List<V> getTop()
      An ordered list of descending top entries.
      Specified by:
      getTop in interface TopData<K>
      See Also:
    • size

      public int size()
      Amount of data indexed and cached.
      Specified by:
      size in interface TopData<K>
    • createKeyArray

      protected abstract K[] createKeyArray(int size)
    • createValueArray

      protected abstract V[] createValueArray(int size)
    • getKey

      protected abstract K getKey(V value)
    • fetchData

      protected abstract V fetchData(K key)