Class ForestChange
Object
ForestChange
- Direct Known Subclasses:
ForestChange.Add,ForestChange.Move,ForestChange.Remove,ForestChange.Reorder
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 operation
Note 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents addition to the forest.static classRepresents moving one or more rows from their current places in forest under the specified position.static classRepresents removal of one or more rows.static classRepresents a complete reorder of the direct children of a given row.static interfaceThe interface to use when making different actions depending on the specific type of the change. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaccept(ForestChange.Visitor visitor) Apply the change to the visitorstatic ForestChangeCreates an "add" forest change.abstract voidapply(ArrayForest forest) Given mutable forest, apply the change to it.static ForestChangemove(long under, long after, LongList rows) Creates a "move" forest change.static ForestChangeremove(LongList rows) Creates a "remove" forest change.static ForestChangereorder(long under, LongList children) Creates a "reorder" forest change.
-
Method Details
-
add
Creates an "add" forest change.- Parameters:
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 added- Returns:
- change
-
move
Creates a "move" forest change.- Parameters:
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 moved- Returns:
- change
-
remove
Creates a "remove" forest change.- Parameters:
rows- a list of rows that were removed from the forest- Returns:
- change
-
reorder
Creates a "reorder" forest change.- Parameters:
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 order- Returns:
- change
-
apply
Given mutable forest, apply the change to it.- Parameters:
forest- forest to change
-
accept
Apply the change to the visitor- Parameters:
visitor- receiver of the call based on the type of this change
-