Skip to content

Commit

Permalink
Used pattern matching and applied IDE suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
calixtus committed Sep 28, 2022
1 parent 5c1b9a6 commit 34c84cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private List<FieldChange> cleanupSingleField(Field fieldKey, BibEntry entry) {
// Run formatter
String newValue = formatter.format(oldValue);

if (oldValue.equals(newValue)) {
if (newValue.equals(oldValue)) {
return Collections.emptyList();
} else {
if (newValue.isEmpty()) {
Expand Down Expand Up @@ -86,7 +86,7 @@ private List<FieldChange> cleanupAllFields(BibEntry entry) {
private List<FieldChange> cleanupAllTextFields(BibEntry entry) {
List<FieldChange> fieldChanges = new ArrayList<>();
Set<Field> fields = new HashSet<>(entry.getFields());
fields.removeAll(FieldFactory.getNotTextFieldNames());
FieldFactory.getNotTextFieldNames().forEach(fields::remove);
for (Field fieldKey : fields) {
if (!fieldKey.equals(InternalField.KEY_FIELD)) {
fieldChanges.addAll(cleanupSingleField(fieldKey, entry));
Expand All @@ -109,11 +109,10 @@ public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof FieldFormatterCleanup)) {
return false;
if (obj instanceof FieldFormatterCleanup that) {
return Objects.equals(field, that.field) && Objects.equals(formatter, that.formatter);
}
FieldFormatterCleanup other = (FieldFormatterCleanup) obj;
return Objects.equals(field, other.field) && Objects.equals(formatter, other.formatter);
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,17 @@ public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof FieldFormatterCleanups)) {
return false;
if (obj instanceof FieldFormatterCleanups other) {
return Objects.equals(actions, other.actions) && (enabled == other.enabled);
}
FieldFormatterCleanups other = (FieldFormatterCleanups) obj;
return Objects.equals(actions, other.actions) && (enabled == other.enabled);
return false;
}

@Override
public String toString() {
return "FieldFormatterCleanups [enabled=" + enabled + ", actions=" + actions + "]";
return "FieldFormatterCleanups{" +
"enabled=" + enabled + "," +
"actions=" + actions +
"}";
}
}

0 comments on commit 34c84cc

Please sign in to comment.