Class DataTree.Mut
- Enclosing class:
DataTree
Note that although the tree itself is mutable, DataTrees and DataLists contained within its
entries may or may not be. Thus, the type itself does not guarantee that its values are mutable.
That said, callers are encouraged to maintain the deep mutability of this Mut. They should avoid storing
DataTree.Immut or DataList.Immut in it without good reason.
-
Nested Class Summary
Nested classes/interfaces inherited from class space.arim.dazzleconf.backend.DataTree
DataTree.Immut, DataTree.Mut -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all datavoidMerges all data in the specified data tree into this one, merging nested sections.voidforEach(BiConsumer<? super @NonNull Object, ? super @NonNull DataEntry> action) Runs an action for each key/value pair.@Nullable DataEntryGets the entry at the specified key, or null if unset.@NonNull DataTree.ImmutGets this data tree as an immutable one.@NonNull DataTree.MutintoMut()Gets this data tree as a mutable one.@Nullable DataEntrySets the entry at the specified key.voidClears any entry at the specified key
-
Constructor Details
-
Mut
public Mut()Creates
-
-
Method Details
-
get
Description copied from class:DataTreeGets the entry at the specified key, or null if unset.If accessing keys based on method names, it is strongly recommended to use the
KeyMapperto map method names to keys. The key mapper is available during both deserialization and serialization. -
forEach
Description copied from class:DataTreeRuns an action for each key/value pair.Iteration maintains the order with which this data tree was created.
-
intoImmut
Description copied from class:DataTreeGets 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
DataTree.Immut, then it may be returned without changes. -
intoMut
Description copied from class:DataTreeGets this data tree as a mutable one.If not mutable, the data is copied to a new tree, which will be made deeply mutable. That is, this function will also be called on any
DataTrees encountered in this tree's entries, andDataList.intoMut()on any data lists likewise.If this instance is already
DataTree.Mut, then it may be returned without changes. -
put
Sets the entry at the specified key. Replaces any existing entry at the key- Parameters:
key- the keyentry- the entry- Returns:
- the previous entry at the key, or null if there is none
- Throws:
IllegalArgumentException- if the provided key is not a valid canonical type
-
remove
Clears any entry at the specified key- Parameters:
key- the key- Throws:
IllegalArgumentException- if the provided key is not a valid canonical type
-
clear
public void clear()Clears all data -
copyFrom
Merges all data in the specified data tree into this one, merging nested sections.If existing key/value pairs are shared between this tree and
source, they will be overwritten and copied fromsource. Key/value pairs that are unique to this tree will be retained.Merging nested trees and lists
If this function encounters a key/value pair that is shared between this tree and
source, and both values areDataTrees, this function will act recursively and merge the two data trees. AnUnsupportedOperationExceptionwill be thrown if this is impossible due to the presence ofDataTree.Immut.Lists are treated differently. If this function encounters a key/value pair that is shared, and both values are lists, this function will overwrite the whole list.
- Parameters:
source- the tree whose entries to copy into this one- Throws:
UnsupportedOperationException- if this tree contains aDataTree.Immutthat cannot be mutated
-