@PublicApi @Immutable public abstract class ForestChange extends Object
ForestChange represents a single change on a forest. A list of ForestChanges represent a difference between two forests. ForestChanges are used only to represent the difference - to optimize event processing, traffic and to provide data to make visual cues about the change. ForestChanges are not used to record history or provide additional information about the forest.
There are several types of the operations, all defined as the inner classes of ForestChange
:
ForestChange.Add
- add operationForestChange.Move
- move operationForestChange.Remove
- remove operationForestChange.Reorder
- reorder operationNote that Reorder
operation can be expressed as a series of Move
operations. Structure can use
either one Reorder
or several Move
changes to express reordering.
All classes are immutable.
Modifier and Type | Class and Description |
---|---|
static class |
ForestChange.Add
Represents addition to the forest.
|
static class |
ForestChange.Move
Represents moving one or more rows from their current places in forest under the specified position.
|
static class |
ForestChange.Remove
Represents removal of one or more rows.
|
static class |
ForestChange.Reorder
Represents a complete reorder of the direct children of a given row.
|
static interface |
ForestChange.Visitor
The interface to use when making different actions depending on the specific type of the change.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
accept(ForestChange.Visitor visitor)
Apply the change to the visitor
|
static ForestChange |
add(long under,
long after,
Forest added)
Creates an "add" forest change.
|
abstract void |
apply(ArrayForest forest)
Given mutable forest, apply the change to it.
|
static ForestChange |
move(long under,
long after,
LongList rows)
Creates a "move" forest change.
|
static ForestChange |
remove(LongList rows)
Creates a "remove" forest change.
|
static ForestChange |
reorder(long under,
LongList children)
Creates a "reorder" forest change.
|
public static ForestChange add(long under, long after, Forest added)
under
- the row under which the addition took place, or 0 if added at the top levelafter
- the previous sibling to the first added row, or 0 if added as a first row under the parentadded
- forest that was addedpublic static ForestChange move(long under, long after, LongList rows)
under
- the row under which the moved rows were placedafter
- the row after which the moved rows were placedrows
- a list of rows that were movedpublic static ForestChange remove(LongList rows)
rows
- a list of rows that were removed from the forestpublic static ForestChange reorder(long under, LongList children)
under
- the row under which the reordering took place, or 0 if added at the top levelchildren
- row IDs of the children, in the desired new orderpublic abstract void apply(@NotNull ArrayForest forest)
forest
- forest to changepublic abstract void accept(ForestChange.Visitor visitor)
visitor
- receiver of the call based on the type of this changeCopyright © 2024 Tempo Software. All Rights Reserved.