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

public final Record FieldChange

extends Record
Class Inheritance
Annotations
@NullMarked
Record Components
entry:BibEntry
the entry whose field changed
field:Field
the field that changed
oldValue:@Nullable String
what the field held before, or null when it had no value
newValue:@Nullable String
what the field holds now, or null when it was removed
Imports
org.jabref.model.entry.BibEntry, org.jabref.model.entry.field.Field, org.jspecify.annotations.NullMarked, .Nullable

One field of one entry, modified, removed or added: what it held before and what it holds now.

Returned by everything in jablib that edits entries — cleanups, formatters, group assignment — so that a caller can report or record what happened. org.jabref.model.undo.UndoableFieldChange is the same four values as an undoable change, and is built from one of these.

Two changes are equal when they describe the same modification of equal entries — the entry is compared as BibEntry compares. org.jabref.model.undo.UndoableFieldChange deliberately does not: a step on the undo stack has to describe that entry object, so it compares the entry by identity. That difference is why the two are not one type.

Field Summary

Modifier and TypeField and Description
private final BibEntry
entry

Record Component accessed by entry().

the entry whose field changed
private final Field
field

Record Component accessed by field().

the field that changed
private final @Nullable String
newValue

Record Component accessed by newValue().

what the field holds now, or null when it was removed
private final @Nullable String
oldValue

Record Component accessed by oldValue().

what the field held before, or null when it had no value

Constructor Summary

AccessConstructor and Description
public
FieldChange(BibEntry entry, Field field, @Nullable String oldValue, @Nullable String newValue)

Method Summary

Modifier and TypeMethod and Description
public BibEntry
entry()

Record Component getter of entry.

Record Component the entry whose field changed

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

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

public Field
field()

Record Component getter of field.

Record Component the field that changed

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public @Nullable String
newValue()

Record Component getter of newValue.

Record Component what the field holds now, or null when it was removed

public @Nullable String
oldValue()

Record Component getter of oldValue.

Record Component what the field held before, or null when it had no value

public String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

entryback to summary
private final BibEntry entry

Record Component accessed by entry().

the entry whose field changed

fieldback to summary
private final Field field

Record Component accessed by field().

the field that changed

newValueback to summary
private final @Nullable String newValue

Record Component accessed by newValue().

what the field holds now, or null when it was removed

oldValueback to summary
private final @Nullable String oldValue

Record Component accessed by oldValue().

what the field held before, or null when it had no value

Constructor Detail

FieldChangeback to summary
public FieldChange(BibEntry entry, Field field, @Nullable String oldValue, @Nullable String newValue)

Method Detail

entryback to summary
public BibEntry entry()

Record Component getter of entry.

Record Component
the entry whose field changed
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).
fieldback to summary
public Field field()

Record Component getter of field.

Record Component
the field that changed
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.

newValueback to summary
public @Nullable String newValue()

Record Component getter of newValue.

Record Component
what the field holds now, or null when it was removed
oldValueback to summary
public @Nullable String oldValue()

Record Component getter of oldValue.

Record Component
what the field held before, or null when it had no value
toStringback to summary
public 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.

Annotations
@Override