Skip to content

Commit

Permalink
Unified some equals (JabRef#1640)
Browse files Browse the repository at this point in the history
* Unified some equals

* Imported correct Objects...
  • Loading branch information
oscargus authored and lenhard committed Jul 29, 2016
1 parent f30bcd5 commit 644b2d7
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/main/java/net/sf/jabref/gui/openoffice/OOBibBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,10 @@ public int compareTo(ComparableMark other) {

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}

if (o instanceof ComparableMark) {
ComparableMark other = (ComparableMark) o;
return (this.position.X == other.position.X) && (this.position.Y == other.position.Y)
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/net/sf/jabref/importer/ImportFileFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public int compareTo(ImportFileFilter o) {

@Override
public boolean equals(Object o) {
if(this == o) {
return true;
}
if (o instanceof ImportFileFilter) {
return name.equals(((ImportFileFilter) o).name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if(obj == null) {
return false;
if (this == obj) {
return true;
}
if(!(obj instanceof ImportFormat)) {
return false;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/net/sf/jabref/logic/groups/ExplicitGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public AbstractGroup deepCopy() {

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ExplicitGroup)) {
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/net/sf/jabref/logic/groups/KeywordGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ public Optional<EntriesGroupChange> remove(List<BibEntry> entriesToRemove) {

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof KeywordGroup)) {
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/net/sf/jabref/logic/groups/SearchGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ public Optional<EntriesGroupChange> remove(List<BibEntry> entriesToRemove) {

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof SearchGroup)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public int compareTo(CitationEntry other) {

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o instanceof CitationEntry) {
CitationEntry other = (CitationEntry) o;
return this.refMarkName.equals(other.refMarkName);
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/net/sf/jabref/logic/openoffice/OOBibStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -888,15 +888,21 @@ public int compareTo(OOBibStyle other) {

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o instanceof OOBibStyle) {
return path.equals(((OOBibStyle) o).path);
OOBibStyle otherStyle = (OOBibStyle) o;
return Objects.equals(path, otherStyle.path) && Objects.equals(name, otherStyle.name)
&& Objects.equals(citProperties, otherStyle.citProperties)
&& Objects.equals(properties, otherStyle.properties);
}
return false;
}

@Override
public int hashCode() {
return Objects.hash(path);
return Objects.hash(path, name, citProperties, properties);
}

private String createAuthorList(String author, int maxAuthors, String andString,
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/net/sf/jabref/model/entry/CustomEntryType.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -78,8 +79,11 @@ public int compareTo(EntryType o) {

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o instanceof CustomEntryType) {
return this.compareTo((CustomEntryType) o) == 0;
return Objects.equals(name, ((CustomEntryType) o).name);
} else {
return false;
}
Expand Down

0 comments on commit 644b2d7

Please sign in to comment.