Class LuaInstances<T>

java.lang.Object
party.iroiro.luajava.LuaInstances<T>
Type Parameters:
T - instance type

public class LuaInstances<T> extends Object
A collection of Jua instances, each labeled with a unique id
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    add()
     
    protected int
    add(T instance)
    Adds the instance to the collection and allocates a new id
    protected int
    addNullable(@Nullable T instance)
     
    protected @Nullable T
    get(int id)
    Returns the instance with the specified id
    protected void
    remove(int id)
    Removes the instance from the collection, marking the id as usable again
    protected int
    Returns the number of elements in this collection

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LuaInstances

      protected LuaInstances()
  • Method Details

    • add

      protected int add(T instance)
      Adds the instance to the collection and allocates a new id
      Parameters:
      instance - element to be added to this collection
      Returns:
      the allocated id
    • addNullable

      protected int addNullable(@Nullable T instance)
    • add

      protected LuaInstances.Token<T> add()
    • get

      protected @Nullable T get(int id)
      Returns the instance with the specified id
      Parameters:
      id - id of the instance to return
      Returns:
      the element with the specified id
    • remove

      protected void remove(int id)
      Removes the instance from the collection, marking the id as usable again

      The user is responsible for AutoCloseable resources.

      Parameters:
      id - the id of the instance to be removed
    • size

      protected int size()
      Returns the number of elements in this collection
      Returns:
      the number of elements in this collection