Whole tree rather than one node, because that is how every group operation already reaches the
model: the group panel edits its nodes in place and writes the root back with
MetaData#setGroups. One record therefore covers adding, removing, moving and reordering, and
undoing any of them is installing the tree that was there before.
Both states are copies of the structure: nodes are mutated in place, so a shared tree would
let a later edit rewrite what this change restores. The org.
each node carries is shared with the live tree, which is enough while operations replace a
node's group rather than mutate it.
The generated equals and hashCode walk both trees and the metadata, whose hash changes as
the library does — fine for comparing two changes, but do not put these in a hash-based
collection.
| Modifier and Type | Field and Description |
|---|---|
| private final Optional | |
| private final Optional | |
| private final MetaData | metaData
Record Component accessed by metaData(). |
| Access | Constructor and Description |
|---|---|
| public | UndoableGroupTreeChange(MetaData metaData, Optional<GroupTreeNode> before, Optional<GroupTreeNode> after)
|
| Modifier and Type | Method and Description |
|---|---|
| public Optional | |
| public ApplyResult | |
| public Optional | |
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public final int | |
| public UndoableGroupTreeChange | |
| public MetaData | |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| after | back to summary |
|---|---|
| private final Optional<GroupTreeNode> after Record Component accessed by after(). | |
| before | back to summary |
|---|---|
| private final Optional<GroupTreeNode> before Record Component accessed by before(). | |
| metaData | back to summary |
|---|---|
| private final MetaData metaData Record Component accessed by metaData(). | |
| UndoableGroupTreeChange | back to summary |
|---|---|
| public UndoableGroupTreeChange(MetaData metaData, Optional<GroupTreeNode> before, Optional<GroupTreeNode> after) | |
| after | back to summary |
|---|---|
| public Optional Record Component getter of after. | |
| apply | back to summary |
|---|---|
| public ApplyResult apply() Implements org. Doc from org. Performs this change. Implementations hold whatever they need to act on — an entry, a string, the database — so that recording a change never requires plumbing a context to the call site. A change that describes one value refuses when the library no longer holds that value, because a command writing on a background thread can have moved it on since, and writing over it would produce a library no step on the stack describes. A change that describes a collection or a whole subtree applies unconditionally: comparing all of it on every apply costs more than the case is worth, and a partial comparison would only look like a check. A change describing one modification performs it or throws, and so always returns
| |
| before | back to summary |
|---|---|
| public Optional Record Component getter of before. | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| inverted | back to summary |
|---|---|
| public UndoableGroupTreeChange inverted() Implements org. Doc from org. The change that reverses this one. Must be an involution:
| |
| metaData | back to summary |
|---|---|
| public MetaData metaData() Record Component getter of metaData. | |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves. | |