Class ListModel<T>

java.lang.Object
com.blackrook.gui.model.indexed.ListModel<T>
Type Parameters:
T - the object type to use.
All Implemented Interfaces:
IndexedModel<T>

public class ListModel<T> extends Object implements IndexedModel<T>
A model that uses a list backing.
Author:
Matthew Tropiano
  • Constructor Details

    • ListModel

      @SafeVarargs public ListModel(T... objects)
      Creates a new list model using a set of objects.
      Parameters:
      objects - the objects to put in the list.
    • ListModel

      public ListModel(Iterable<T> iterable)
      Creates a new list model using an iterable set of objects.
      Parameters:
      iterable - the iterable list of objects to put in the list.
  • Method Details

    • getValueByIndex

      public T getValueByIndex(int index)
      Description copied from interface: IndexedModel
      Returns the value at a specific index number in this model. If this index number is invalid, this returns null.
      Specified by:
      getValueByIndex in interface IndexedModel<T>
      Parameters:
      index - the desired index.
      Returns:
      the corresponding value, or null if not found.
    • getIndexByValue

      public int getIndexByValue(T value)
      Description copied from interface: IndexedModel
      Returns a specific index number of a value in this model. If the value is not in this model, this returns -1.
      Specified by:
      getIndexByValue in interface IndexedModel<T>
      Parameters:
      value - the desired value.
      Returns:
      the corresponding index, or -1 if not found.
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface IndexedModel<T>
      Returns:
      true if this contains no values, false otherwise.
    • size

      public int size()
      Specified by:
      size in interface IndexedModel<T>
      Returns:
      the amount of values in this model.