Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix saving triggers metadata changed #9165

Merged
merged 3 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- The global default directory for storing PDFs is now the subdirectory "JabRef" in the user's home.
- We reworked the Define study parameters dialog. [#9123](https://github.com/JabRef/jabref/pull/9123)
- We simplified the actions to fast-resolve duplicates to 'Keep Left', 'Keep Right', 'Keep Both' and 'Keep Merged'. [#9056](https://github.com/JabRef/jabref/issues/9056)

- We fixed an issue where a message about changed metadata would occur on saving although nothing changed [#9159](https://github.com/JabRef/jabref/issues/9159)

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ public Formatter getFormatter() {
}

@Override
public boolean equals(Object o) {
if (this == o) {
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (o instanceof FieldFormatterCleanup) {
FieldFormatterCleanup that = (FieldFormatterCleanup) o;
return Objects.equals(field, that.field) && Objects.equals(formatter, that.formatter);
if (!(obj instanceof FieldFormatterCleanup)) {
return false;
}
return false;
FieldFormatterCleanup other = (FieldFormatterCleanup) obj;
return Objects.equals(field, other.field) && Objects.equals(formatter, other.formatter);
}
Comment on lines -108 to 117
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new code seems to be the equial to the old one. ^^.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just used eclipse to regenerate it to have it consistent with others


@Override
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/org/jabref/logic/cleanup/FieldFormatterCleanups.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,26 @@ private static Formatter getFormatterFromString(String formatterName) {
}
return new IdentityFormatter();
}

@Override
public int hashCode() {
return Objects.hash(actions, enabled);
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof FieldFormatterCleanups)) {
return false;
}
FieldFormatterCleanups other = (FieldFormatterCleanups) obj;
return Objects.equals(actions, other.actions) && (enabled == other.enabled);
}

@Override
public String toString() {
return "FieldFormatterCleanups [enabled=" + enabled + ", actions=" + actions + "]";
}
Comment on lines +209 to +230
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for putting in the implementations here. I googled and found

By default, two objects are equal if and only if they are refer to the same memory location

}
7 changes: 6 additions & 1 deletion src/main/java/org/jabref/model/metadata/ContentSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
if ((o == null) || (getClass() != o.getClass())) {
return false;
}

Expand All @@ -35,6 +35,11 @@ public boolean equals(Object o) {
Objects.equals(values, that.values);
}

@Override
public String toString() {
return "ContentSelector [field=" + field + ", values=" + values + "]";
}

@Override
public int hashCode() {
return Objects.hash(field, values);
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/org/jabref/model/metadata/MetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,14 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(groupsRoot.getValue(), encoding, encodingExplicitlySupplied, saveOrderConfig, citeKeyPatterns, userFileDirectory,
defaultCiteKeyPattern, saveActions, mode, isProtected, defaultFileDirectory);
return Objects.hash(isProtected, groupsRoot.getValue(), encoding, encodingExplicitlySupplied, saveOrderConfig, citeKeyPatterns, userFileDirectory,
laTexFileDirectory, defaultCiteKeyPattern, saveActions, mode, defaultFileDirectory, contentSelectors);
}

@Override
public String toString() {
return "MetaData [citeKeyPatterns=" + citeKeyPatterns + ", userFileDirectory=" + userFileDirectory + ", laTexFileDirectory=" + laTexFileDirectory + ", groupsRoot=" + groupsRoot + ", encoding=" + encoding + ", saveOrderConfig=" + saveOrderConfig + ", defaultCiteKeyPattern=" + defaultCiteKeyPattern + ", saveActions=" + saveActions + ", mode=" + mode + ", isProtected=" + isProtected + ", defaultFileDirectory=" + defaultFileDirectory + ", contentSelectors=" + contentSelectors + ", encodingExplicitlySupplied=" + encodingExplicitlySupplied + "]";
}
koppor marked this conversation as resolved.
Show resolved Hide resolved
koppor marked this conversation as resolved.
Show resolved Hide resolved


}