Interface NonNullList<T>

All Superinterfaces:
Collection<T>, Iterable<T>, List<T>, SequencedCollection<T>
All Known Implementing Classes:
NonNullList.ListProxy

public interface NonNullList<T> extends List<T>
Implements a list which is strict in all its elements. The implementation is done by delegation to some peer object from a predefined Java runtime class. Optional operations are supported whenever the peer object supports them.
  • Method Details

    • newInstance

      static <T2> NonNullList<T2> newInstance()
      Creates a new instance and uses a ArrayList as its peer.
    • newInstance

      static <T2> NonNullList<T2> newInstance(Supplier<List<T2>> supplier)
      Creates a new instance and uses a list returned by the given supplier as its peer.
      Parameters:
      supplier - must deliver an empty instance of the intended peer class.
      Throws:
      IllegalArgumentException - if the delivered peer is not empty.
    • copyOf

      static <T2> NonNullList<T2> copyOf(List<T2> proto)
      Creates a new instance and uses the data from the given list. Uses Collections.duplicate(List) to create a copy with similar behaviour, to be used as peer.
      Parameters:
      proto - the data for the new list
      Throws:
      NullPointerException - if the data contains null values.
    • singleton

      static <T> NonNullList<T> singleton(T x)