Class LockableList<T>

java.lang.Object
com.hedera.hashgraph.sdk.LockableList<T>
Type Parameters:
T - the lockable list type
All Implemented Interfaces:
Iterable<T>

class LockableList<T> extends Object implements Iterable<T>
Internal utility class for a new lockable list type.
  • Constructor Details

    • LockableList

      LockableList()
      Constructor.
    • LockableList

      LockableList(ArrayList<T> list)
      Assign a list of items to this list instance.
      Parameters:
      list - the lockable list
  • Method Details

    • requireNotLocked

      void requireNotLocked()
      Verify that this list instance is not locked.
    • ensureCapacity

      LockableList<T> ensureCapacity(int capacity)
      Make sure that this list instance has the requested capacity.
      Parameters:
      capacity - the minimum capacity
      Returns:
      the updated list
    • setList

      LockableList<T> setList(List<T> list)
      Assign a list to this list instance.
      Parameters:
      list - the lockable list to assign
      Returns:
      the updated list
    • getList

      ArrayList<T> getList()
      Extract the lockable list.
      Returns:
      the lockable list
    • add

      LockableList<T> add(T... elements)
      Add items to this list instance.
      Parameters:
      elements - the items to add
      Returns:
      the updated list
    • addAll

      LockableList<T> addAll(Collection<? extends T> elements)
      Add all items to this list instance.
      Parameters:
      elements - the list of items to add
      Returns:
      the updated list
    • shuffle

      public LockableList<T> shuffle()
      Shuffle the list items.
      Returns:
      the updated list
    • remove

      LockableList<T> remove(T element)
      Remove an item from this list instance.
      Parameters:
      element - the element to remove
      Returns:
      the updated list
    • getCurrent

      T getCurrent()
      Extract the current list.
      Returns:
      the current list item
    • getNext

      T getNext()
      Extract the next item.
      Returns:
      the next list item
    • get

      T get(int index)
      Get a specific list item.
      Parameters:
      index - the index of the item
      Returns:
      the item
    • set

      LockableList<T> set(int index, T item)
      Assign an item at the specified index.
      Parameters:
      index - the index of the item
      item - the item
      Returns:
      the updated list
    • setIfAbsent

      LockableList<T> setIfAbsent(int index, T item)
      Assign an item to the list if: - item at index is null - index is not greater than size of existing list
      Parameters:
      index - the requested index
      item - the item
      Returns:
      the updated list
    • advance

      int advance()
      Advance to the next item wraps if needed.
      Returns:
      the next index wrapped
    • isEmpty

      boolean isEmpty()
      Is the list empty?
      Returns:
      is the list empty
    • isLocked

      boolean isLocked()
      Is the list locked?
      Returns:
      is the list locked
    • setLocked

      LockableList<T> setLocked(boolean locked)
      Assign the lock status.
      Parameters:
      locked - the lock status
      Returns:
      the updated list
    • size

      int size()
      How many items are in the list.
      Returns:
      the size of the list
    • setIndex

      LockableList<T> setIndex(int index)
      Assign the current list index.
      Parameters:
      index - the index
      Returns:
      the updated list
    • getIndex

      int getIndex()
      What is the current index.
      Returns:
      the index of the current item
    • clear

      LockableList<T> clear()
      Empty the list.
      Returns:
      an empty list
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>