Class NonNullList<E>

All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, SequencedCollection<E>

public class NonNullList<E> extends AbstractList<E>
  • Field Details

    • list

      private final List<E> list
    • defaultValue

      @Nullable private final E defaultValue
  • Constructor Details

    • NonNullList

      protected NonNullList(List<E> p_122777_, @Nullable E p_122778_)
  • Method Details

    • codecOf

      public static <E> com.mojang.serialization.Codec<NonNullList<E>> codecOf(com.mojang.serialization.Codec<E> entryCodec)
      Neo: utility method to construct a Codec for a NonNullList
      Type Parameters:
      E - the element type
      Parameters:
      entryCodec - the codec to use for the elements
      Returns:
      a codec that encodes as a list, and decodes into NonNullList
    • copyOf

      public static <E> NonNullList<E> copyOf(Collection<? extends E> entries)
      Neo: utility method to construct an immutable NonNullList from a given collection
      Type Parameters:
      E - the type of the elements in the list
      Parameters:
      entries - the collection to make a copy of
      Returns:
      a new immutable NonNullList
      Throws:
      NullPointerException - if entries is null, or if it contains any nulls
    • create

      public static <E> NonNullList<E> create()
    • createWithCapacity

      public static <E> NonNullList<E> createWithCapacity(int p_182648_)
    • withSize

      public static <E> NonNullList<E> withSize(int p_122781_, E p_122782_)
    • of

      @SafeVarargs public static <E> NonNullList<E> of(E p_122784_, E... p_122785_)
    • get

      @Nonnull public E get(int p_122791_)
      Specified by:
      get in interface List<E>
      Specified by:
      get in class AbstractList<E>
    • set

      public E set(int p_122795_, E p_122796_)
      Specified by:
      set in interface List<E>
      Overrides:
      set in class AbstractList<E>
    • add

      public void add(int p_122787_, E p_122788_)
      Specified by:
      add in interface List<E>
      Overrides:
      add in class AbstractList<E>
    • remove

      public E remove(int p_122793_)
      Specified by:
      remove in interface List<E>
      Overrides:
      remove in class AbstractList<E>
    • size

      public int size()
      Specified by:
      size in interface Collection<E>
      Specified by:
      size in interface List<E>
      Specified by:
      size in class AbstractCollection<E>
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<E>
      Specified by:
      clear in interface List<E>
      Overrides:
      clear in class AbstractList<E>