Class DataList.Immut

java.lang.Object
space.arim.dazzleconf.backend.DataList
space.arim.dazzleconf.backend.DataList.Immut
Enclosing class:
DataList

public static final class DataList.Immut extends DataList
A data list which is immutable.

This type guarantees that all of its elements are immutable (deep immutability). That is, DataTrees and DataLists contained within this list's element entries will always be immutable.

  • Constructor Details

    • Immut

      public Immut()
      Creates an empty data list
    • Immut

      public Immut(@NonNull DataEntry @NonNull ... entries)
      Creates from the given elements.

      The array is copied to ensure immutability, and each entry is checked that it is not null.

      Parameters:
      entries - the elements, none of which can be null
    • Immut

      public Immut(@NonNull Collection<@NonNull DataEntry> entries)
      Creates from the given elements.

      The collection is copied to ensure immutability, and each entry is checked that it is not null. The encounter order of the collection becomes the order of this list.

      Parameters:
      entries - the elements, none of which can be null
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Description copied from class: DataList
      Whether this data list is devoid of elements
      Specified by:
      isEmpty in class DataList
      Returns:
      true if empty
    • size

      public int size()
      Description copied from class: DataList
      The number of elements in this data tree indicates its size
      Specified by:
      size in class DataList
      Returns:
      the size of this data tree
    • intoImmut

      public @NonNull DataList.Immut intoImmut()
      Description copied from class: DataList
      Gets this data tree as an immutable one.

      The data contained within this DataTree is moved to an immutable instance. The old instance may still be used, but the implementation of this method may be optimized for the case that it is not.

      If this instance is already DataList.Immut, then it may be returned without changes.

      Specified by:
      intoImmut in class DataList
      Returns:
      an immutable data tree
    • intoMut

      public @NonNull DataList.Mut intoMut()
      Description copied from class: DataList
      Gets this data list as a mutable one.

      If not mutable, the data is copied to a new list, which will be made deeply mutable. That is, this function will also be called on any DataLists encountered in this list's entries, and DataTree.intoMut() on any data trees likewise.

      If this instance is already DataList.Immut, then it may be returned without changes.

      Specified by:
      intoMut in class DataList
      Returns:
      this list if mutable, or a mutable copy if needed
    • get

      public @NonNull DataEntry get(int idx)
      Description copied from class: DataList
      Gets the entry at the specified index.
      Specified by:
      get in class DataList
      Parameters:
      idx - the index
      Returns:
      the entry
    • forEach

      public void forEach(Consumer<? super @NonNull DataEntry> action)
      Description copied from class: DataList
      Runs an action for each element.
      Specified by:
      forEach in class DataList
      Parameters:
      action - the action