Interface LuaTable<K,V>

Type Parameters:
K - The type of keys in a table, will typically be a wildcard.
V - The type of values in a table, will typically be a wildcard.
All Superinterfaces:
Map<K,V>
All Known Implementing Classes:
ObjectLuaTable

public interface LuaTable<K,V> extends Map<K,V>
A view of a Lua table.

Much like IArguments, this allows for convenient parsing of fields from a Lua table.

See Also:
  • Method Details

    • get

      default @Nullable Object get(int index)
      Return the value to which a specific integer key is mapped, or null if there is no mapping for the key.

      This should be used when accessing integer keys, as numeric keys within the table are typically normalised to doubles.

      Parameters:
      index - The key to look up.
      Returns:
      The corresponding value, or null if not present.
    • length

      default int length()
      Compute the length of the array part of this table.
      Returns:
      This table's length.
    • getDouble

      default double getDouble(int index) throws LuaException
      Get an array entry as a double.
      Parameters:
      index - The index in the table, starting at 1.
      Returns:
      The entry's value.
      Throws:
      LuaException - If the value is not a number.
      Since:
      1.116
      See Also:
    • getDouble

      default double getDouble(String key) throws LuaException
      Get a table entry as a double.
      Parameters:
      key - The name of the field in the table.
      Returns:
      The field's value.
      Throws:
      LuaException - If the value is not a number.
      Since:
      1.116
      See Also:
    • getLong

      default long getLong(int index) throws LuaException
      Get an array entry as an integer.
      Parameters:
      index - The index in the table, starting at 1.
      Returns:
      The entry's value.
      Throws:
      LuaException - If the value is not an integer.
    • getLong

      default long getLong(String key) throws LuaException
      Get a table entry as an integer.
      Parameters:
      key - The name of the field in the table.
      Returns:
      The field's value.
      Throws:
      LuaException - If the value is not an integer.
    • getInt

      default int getInt(int index) throws LuaException
      Get an array entry as an integer.
      Parameters:
      index - The index in the table, starting at 1.
      Returns:
      The entry's value.
      Throws:
      LuaException - If the value is not an integer.
    • getInt

      default int getInt(String key) throws LuaException
      Get a table entry as an integer.
      Parameters:
      key - The name of the field in the table.
      Returns:
      The field's value.
      Throws:
      LuaException - If the value is not an integer.
    • getFiniteDouble

      default double getFiniteDouble(int index) throws LuaException
      Get an argument as a finite number (not infinite or NaN).
      Parameters:
      index - The index in the table, starting at 1.
      Returns:
      The entry's value.
      Throws:
      LuaException - If the value is not finite.
      Since:
      1.116
    • getFiniteDouble

      default double getFiniteDouble(String key) throws LuaException
      Get an argument as a finite number (not infinite or NaN).
      Parameters:
      key - The name of the field in the table.
      Returns:
      The field's value.
      Throws:
      LuaException - If the value is not finite.
      Since:
      1.116
    • getBoolean

      default boolean getBoolean(int index) throws LuaException
      Get an array entry as a boolean.
      Parameters:
      index - The index in the table, starting at 1.
      Returns:
      The entry's value.
      Throws:
      LuaException - If the value is not a boolean.
      Since:
      1.116
    • getBoolean

      default boolean getBoolean(String key) throws LuaException
      Get a table entry as a boolean.
      Parameters:
      key - The name of the field in the table.
      Returns:
      The field's value.
      Throws:
      LuaException - If the value is not a boolean.
      Since:
      1.116
    • getString

      default String getString(int index) throws LuaException
      Get an array entry as a string.
      Parameters:
      index - The index in the table, starting at 1.
      Returns:
      The entry's value.
      Throws:
      LuaException - If the value is not a string.
      Since:
      1.116
    • getString

      default String getString(String key) throws LuaException
      Get a table entry as a string.
      Parameters:
      key - The name of the field in the table.
      Returns:
      The field's value.
      Throws:
      LuaException - If the value is not a string.
      Since:
      1.116
    • getTable

      default Map<?,?> getTable(int index) throws LuaException
      Get an array entry as a table.

      The returned table may be converted into a LuaTable (using ObjectLuaTable) for easier parsing of table keys.

      Parameters:
      index - The index in the table, starting at 1.
      Returns:
      The entry's value.
      Throws:
      LuaException - If the value is not a table.
      Since:
      1.116
    • getTable

      default Map<?,?> getTable(String key) throws LuaException
      Get a table entry as a table.

      The returned table may be converted into a LuaTable (using ObjectLuaTable) for easier parsing of table keys.

      Parameters:
      key - The name of the field in the table.
      Returns:
      The field's value.
      Throws:
      LuaException - If the value is not a table.
      Since:
      1.116
    • optDouble

      default Optional<Double> optDouble(int index) throws LuaException
      Get an array entry as a double.
      Parameters:
      index - The index in the table, starting at 1.
      Returns:
      The entry's value, or Optional.empty() if not present.
      Throws:
      LuaException - If the value is not a number.
      Since:
      1.116
      See Also:
    • optDouble

      default Optional<Double> optDouble(String key) throws LuaException
      Get a table entry as a double.
      Parameters:
      key - The name of the field in the table.
      Returns:
      The field's value, or Optional.empty() if not present.
      Throws:
      LuaException - If the value is not a number.
      Since:
      1.116
      See Also:
    • optLong

      default Optional<Long> optLong(int index) throws LuaException
      Get an array entry as an integer.
      Parameters:
      index - The index in the table, starting at 1.
      Returns:
      The entry's value, or Optional.empty() if not present.
      Throws:
      LuaException - If the value is not an integer.
      Since:
      1.116
    • optLong

      default Optional<Long> optLong(String key) throws LuaException
      Get a table entry as an integer.
      Parameters:
      key - The name of the field in the table.
      Returns:
      The field's value, or Optional.empty() if not present.
      Throws:
      LuaException - If the value is not an integer.
      Since:
      1.116
    • optInt

      default Optional<Integer> optInt(int index) throws LuaException
      Get an array entry as an integer.
      Parameters:
      index - The index in the table, starting at 1.
      Returns:
      The entry's value, or Optional.empty() if not present.
      Throws:
      LuaException - If the value is not an integer.
      Since:
      1.116
    • optInt

      default Optional<Integer> optInt(String key) throws LuaException
      Get a table entry as an integer.
      Parameters:
      key - The name of the field in the table.
      Returns:
      The field's value, or Optional.empty() if not present.
      Throws:
      LuaException - If the value is not an integer.
      Since:
      1.116
    • optFiniteDouble

      default Optional<Double> optFiniteDouble(int index) throws LuaException
      Get an argument as a finite number (not infinite or NaN).
      Parameters:
      index - The index in the table, starting at 1.
      Returns:
      The entry's value, or Optional.empty() if not present.
      Throws:
      LuaException - If the value is not finite.
      Since:
      1.116
    • optFiniteDouble

      default Optional<Double> optFiniteDouble(String key) throws LuaException
      Get an argument as a finite number (not infinite or NaN).
      Parameters:
      key - The name of the field in the table.
      Returns:
      The field's value, or Optional.empty() if not present.
      Throws:
      LuaException - If the value is not finite.
      Since:
      1.116
    • optBoolean

      default Optional<Boolean> optBoolean(int index) throws LuaException
      Get an array entry as a boolean.
      Parameters:
      index - The index in the table, starting at 1.
      Returns:
      The entry's value, or Optional.empty() if not present.
      Throws:
      LuaException - If the value is not a boolean.
      Since:
      1.116
    • optBoolean

      default Optional<Boolean> optBoolean(String key) throws LuaException
      Get a table entry as a boolean.
      Parameters:
      key - The name of the field in the table.
      Returns:
      The field's value, or Optional.empty() if not present.
      Throws:
      LuaException - If the value is not a boolean.
      Since:
      1.116
    • optString

      default Optional<String> optString(int index) throws LuaException
      Get an array entry as a double.
      Parameters:
      index - The index in the table, starting at 1.
      Returns:
      The entry's value, or Optional.empty() if not present.
      Throws:
      LuaException - If the value is not a string.
      Since:
      1.116
    • optString

      default Optional<String> optString(String key) throws LuaException
      Get a table entry as a string.
      Parameters:
      key - The name of the field in the table.
      Returns:
      The field's value, or Optional.empty() if not present.
      Throws:
      LuaException - If the value is not a string.
      Since:
      1.116
    • optTable

      default Optional<Map<?,?>> optTable(int index) throws LuaException
      Get an array entry as a table.

      The returned table may be converted into a LuaTable (using ObjectLuaTable) for easier parsing of table keys.

      Parameters:
      index - The index in the table, starting at 1.
      Returns:
      The entry's value, or Optional.empty() if not present.
      Throws:
      LuaException - If the value is not a table.
      Since:
      1.116
    • optTable

      default Optional<Map<?,?>> optTable(String key) throws LuaException
      Get a table entry as a table.

      The returned table may be converted into a LuaTable (using ObjectLuaTable) for easier parsing of table keys.

      Parameters:
      key - The name of the field in the table.
      Returns:
      The field's value, or Optional.empty() if not present.
      Throws:
      LuaException - If the value is not a table.
      Since:
      1.116
    • put

      default @Nullable V put(K o, V o2)
      Specified by:
      put in interface Map<K,V>
    • remove

      default V remove(Object o)
      Specified by:
      remove in interface Map<K,V>
    • putAll

      default void putAll(Map<? extends K, ? extends V> map)
      Specified by:
      putAll in interface Map<K,V>
    • clear

      default void clear()
      Specified by:
      clear in interface Map<K,V>