GitBranch.equals(): simplify, allow subclasses, add null-check to the super.equals

This commit is contained in:
Kirill Likhodedov
2012-10-18 17:54:01 +04:00
parent 5a04d05c4a
commit 04126e4be6
2 changed files with 7 additions and 3 deletions
+3 -3
View File
@@ -109,9 +109,9 @@ public class GitBranch extends GitReference {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
if (!super.equals(o)) {
return false;
}
// Reusing equals from super: only the name is important:
// branches are considered equal even if they point to different commits.
@@ -50,6 +50,10 @@ public abstract class GitReference implements Comparable<GitReference> {
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
return obj instanceof GitReference && getFullName().equals(((GitReference)obj).getFullName());
}