Changes<TAdd, TUpdate>#
The edits to one record kind: records to add, partial updates and IDs to remove. Each SchedulingChanges starts with an empty instance per record kind, and edits go into its lists.
Field of SchedulingChanges |
Type |
|---|---|
tasks |
Changes<TaskData, TaskUpdate> |
links |
Changes<LinkAdd, LinkUpdate> |
resources |
Changes<ResourceData, ResourceUpdate> |
assignments |
Changes<AssignmentData, AssignmentUpdate> |
Declaration#
| Type parameter | Description |
|---|---|
TAdd |
The full record to add: TaskData, LinkAdd, ResourceData or AssignmentData. |
TUpdate |
The partial update record: TaskUpdate, LinkUpdate, ResourceUpdate or AssignmentUpdate. |
Both type arguments implement DeepCloneable<T>, so deepClone() can copy every record in the lists.
Constructors#
Changes()#
public
Creates an instance with all three lists empty.
Fields#
| Field | Type | Default | Description |
|---|---|---|---|
add |
Vec<TAdd> |
empty | Records to add. The ID of each record must not exist yet. A LinkAdd or AssignmentData with a null ID gets a generated one. |
update |
Vec<TUpdate> |
empty | Partial updates. Each record names an existing ID. Its Patch<T> fields keep, clear or set each value. |
remove |
Vec<Id> |
empty | IDs of existing records to remove. |
Each list entry is one operation. In ApplyReport, an operation's path is its group, its list and its index: tasks.add[0], links.remove[1], assignments.update[2]. An unknown ID in update or remove, or an ID in add that already exists, rejects that operation. Removing a record also removes the records that depend on it, and ApplyReport.effects lists them. For the order in which the lists run, see SchedulingChanges.
The lists are mutable, so entries can go straight into a field: changes.tasks.update.add(new TaskUpdate(Id.num(1)).withDuration(Patch.of(3.0))). Keep the fields non-null: a null list makes the call that reads the change set throw NullPointerException.
Methods#
withAdd#
public Changes
public Changes
Sets add and returns this instance for chaining. The Vec overload stores the given list itself. The Collection overload copies the elements into a new Vec, so List.of(...) works.
Returns - this Changes.
withUpdate#
public Changes
public Changes
Sets update and returns this instance for chaining. The overloads behave as in withAdd.
Returns - this Changes.
withRemove#
public Changes
public Changes
Sets remove and returns this instance for chaining. The overloads behave as in withAdd.
Returns - this Changes.
deepClone#
public Changes
Returns a copy with new lists. Each record in add and update is deep-copied. remove holds the same Id values, which are immutable.
Returns - a new, independent Changes.
copy#
public Changes
Returns a shallow copy. The copy shares the three Vec instances with the original, so adding to a list of one shows up in the other.
Returns - a new Changes that shares its lists.
equals, hashCode, toString#
public boolean
public int
public String
Inherited from ValueRecord. Two Changes are equal when their add, update and remove lists are equal. toString() lists the three fields, for logging.
Example#
Add, update and remove tasks in one change set:
;
;
Related#
SchedulingChanges- the change set with oneChangesper record kindPatch<T>- the fields of the update recordsApplyReport- the operation paths and side effects afterapply- Data Updates - building change sets