Class DataList
- Direct Known Subclasses:
DataList.Immut,DataList.Mut
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 ClassesModifier and TypeClassDescriptionstatic final classA data list which is immutable.static final classA data list which can be modified. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanabstract voidRuns an action for each element.abstract @NonNull DataEntryget(int idx) Gets the entry at the specified index.final inthashCode()abstract @NonNull DataList.ImmutGets this data tree as an immutable one.abstract @NonNull DataList.MutintoMut()Gets this data list as a mutable one.abstract booleanisEmpty()Whether this data list is devoid of elementsabstract intsize()The number of elements in this data tree indicates its sizefinal StringtoString()
-
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
Gets this data tree as an immutable one.The data contained within this
DataTreeis 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
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, andDataTree.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
Gets the entry at the specified index.- Parameters:
idx- the index- Returns:
- the entry
- Throws:
IndexOutOfBoundsException- if the index is out of bounds
-
forEach
Runs an action for each element.- Parameters:
action- the action
-
equals
-
hashCode
public final int hashCode() -
toString
-