Verified Owner
Top Description Fields Constructors Methods
org.jabref.model.undo

public final Record ChangeSet

extends Record
implements BibChange
Class Inheritance
All Implemented Interfaces
org.jabref.model.undo.BibChange
Annotations
@NullMarked
Record Components
name:String 
changes:List<BibChange> 
Imports
java.util.ArrayList, .List, org.jspecify.annotations.NullMarked, org.slf4j.Logger, .LoggerFactory

A group of changes that the user performed as one action, and that undo therefore has to reverse as one action.

A ChangeSet is itself a BibChange, so sets may nest — a command delegating to a helper does not have to flatten anything. Only the outermost set is pushed onto the undo stack, so one user action stays one undo step regardless of nesting.

name is the only text in the change model, and it exists at this granularity because that is the granularity the user acts in: "Merge entries", not "change field author of entry X".

It is shown to the user: the notification after an undo names the step, and the warning apply logs when part of a set fails carries it too. So it is named as the user would recognise the action — from org.jabref.gui.actions.Action#getText where the step comes from a command, from a localized string otherwise. A developer token here is a defect.

Field Summary

Modifier and TypeField and Description
private final List<BibChange>
changes

Record Component accessed by changes().

private static final Logger
private final String
name

Record Component accessed by name().

Constructor Summary

AccessConstructor and Description
public
ChangeSet(String name, List<BibChange> changes)

Method Summary

Modifier and TypeMethod and Description
public ApplyResult
apply()

Implements org.jabref.model.undo.BibChange.apply.

Applies every change, continuing past a failing one, and reports what did not make it.

public List<BibChange>
changes()

Record Component getter of changes.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public ChangeSet
inverted()

Implements org.jabref.model.undo.BibChange.inverted.

Reverses the order and inverts each element — both are required for a group to undo correctly, because later changes may depend on earlier ones.

public boolean
public String
name()

Record Component getter of name.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

changesback to summary
private final List<BibChange> changes

Record Component accessed by changes().

LOGGERback to summary
private static final Logger LOGGER
nameback to summary
private final String name

Record Component accessed by name().

Constructor Detail

ChangeSetback to summary
public ChangeSet(String name, List<BibChange> changes)

Method Detail

applyback to summary
public ApplyResult apply()

Implements org.jabref.model.undo.BibChange.apply.

Applies every change, continuing past a failing one, and reports what did not make it.

Aborting midway would leave the library in a state that is neither the old nor the new one and that no subsequent undo could describe, so a partially applied set is preferred over a partially reverted one. Failures are not propagated, because a caller half-way through a set has no meaningful recovery; they are returned, because a caller that believes the whole set was applied has been told something untrue.

Two things come back as failures: an element that threw, and an element that refused because the library no longer holds what it recorded. Failures of nested sets travel up as they are, so what comes back names the changes that failed rather than the sets that contained them.

Annotations
@Override
changesback to summary
public List<BibChange> changes()

Record Component getter of changes.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

invertedback to summary
public ChangeSet inverted()

Implements org.jabref.model.undo.BibChange.inverted.

Reverses the order and inverts each element — both are required for a group to undo correctly, because later changes may depend on earlier ones.

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()
nameback to summary
public String name()

Record Component getter of name.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

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.