Class DataList

java.lang.Object
space.arim.dazzleconf.backend.DataList
Direct Known Subclasses:
DataList.Immut, DataList.Mut

public abstract class DataList extends Object
A list of in-memory configuration data.

This is the list version of DataTree. Element values are wrapped by DataEntry and must be one of the canonical types:

  • String
  • primitives represented by their boxed types
  • DataTree or DataList for nesting

Mutability

Mutability of this class is not defined. Please use DataList.Mut or DataList.Immut if you need mutable or immutable versions, or see the package javadoc for more information on the mutability model we use.

Equality

A data list is equal to another if they have the same entries in the same order. Mutability is not considered. Note that DataEntry does not consider metadata, like comments or line number, in its equality contract.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    A data list which is immutable.
    static final class 
    A data list which can be modified.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
     
    abstract void
    forEach(Consumer<? super @NonNull DataEntry> action)
    Runs an action for each element.
    abstract @NonNull DataEntry
    get(int idx)
    Gets the entry at the specified index.
    final int
     
    abstract @NonNull DataList.Immut
    Gets this data tree as an immutable one.
    abstract @NonNull DataList.Mut
    Gets this data list as a mutable one.
    abstract boolean
    Whether this data list is devoid of elements
    abstract int
    The number of elements in this data tree indicates its size
    final String
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DataList

      public DataList()
  • Method Details

    • isEmpty

      @Pure public abstract boolean isEmpty()
      Whether this data list is devoid of elements
      Returns:
      true if empty
    • size

      @Pure public abstract int size()
      The number of elements in this data tree indicates its size
      Returns:
      the size of this data tree
    • intoImmut

      @SideEffectFree public abstract @NonNull DataList.Immut intoImmut()
      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.

      Returns:
      an immutable data tree
    • intoMut

      @SideEffectFree public abstract @NonNull DataList.Mut intoMut()
      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.

      Returns:
      this list if mutable, or a mutable copy if needed
    • get

      @Pure public abstract @NonNull DataEntry get(int idx)
      Gets the entry at the specified index.
      Parameters:
      idx - the index
      Returns:
      the entry
      Throws:
      IndexOutOfBoundsException - if the index is out of bounds
    • forEach

      @SideEffectFree public abstract void forEach(Consumer<? super @NonNull DataEntry> action)
      Runs an action for each element.
      Parameters:
      action - the action
    • equals

      public final boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public final String toString()
      Overrides:
      toString in class Object