Interface Table<R extends Record>


@NonExtendable @Blocking public interface Table<R extends Record>
Rows of type R, each under a String key. Every write commits immediately, unless it runs inside ModStorage.transaction(Runnable). Calls block; on the main thread they are only allowed during startup.
  • Method Details

    • set

      void set(String key, R value)
      Stores value under key, replacing an existing row.
    • setAll

      void setAll(Map<String,R> values)
      Stores every entry in one transaction.
    • get

      Optional<R> get(String key)
    • getAll

      @Unmodifiable Map<String,R> getAll(Collection<String> keys)
      The rows of the given keys that exist.
    • contains

      boolean contains(String key)
    • delete

      boolean delete(String key)
      Returns:
      whether a row was removed
    • deleteAll

      int deleteAll(Collection<String> keys)
      Returns:
      the number of rows removed
    • keys

      @Unmodifiable List<String> keys()
      Every key, sorted.
    • forEach

      void forEach(BiConsumer<String,R> action)
      Calls action for every row, sorted by key, without loading all rows at once. Storage of every mod waits until it returns, so action must not wait for other threads.
    • count

      long count()
    • update

      R update(String key, UnaryOperator<R> change, Supplier<R> initial)
      Replaces the row under key with change applied to it, or to initial when there is none, in one transaction: no other write comes in between. As in ModStorage.transaction(Runnable), change and initial must not wait for other threads.
      Returns:
      the stored value