package org.hanuna.gitalk.graph.elements;

import org.hanuna.gitalk.commitmodel.Commit;
import org.jetbrains.annotations.NotNull;

/**
 * @author erokhins
 */
public class Branch {
    private final Commit upCommit;
    private final Commit downCommit;

    public Branch(@NotNull Commit upCommit, @NotNull Commit downCommit) {
        this.upCommit = upCommit;
        this.downCommit = downCommit;
    }

    public Branch(Commit commit) {
        this(commit, commit);
    }


    public int getBranchNumber() {
        return upCommit.hashCode() + downCommit.hashCode();
    }

    @Override
    public String toString() {
        if (upCommit == downCommit) {
            return upCommit.hash().toStrHash();
        } else {
            return upCommit.hash().toStrHash() + '#' + downCommit.hash().toStrHash();
        }
    }
}

@@ -159,16 +159,22 @@
 %0Apublic 
+final 
 class Br
@@ -424,16 +424,25 @@
  Branch(
+@NotNull 
 Commit c
@@ -487,17 +487,16 @@
 %0A    %7D%0A%0A
-%0A
     publ
@@ -585,24 +585,418 @@
 e();%0A    %7D%0A%0A
+    @Override%0A    public int hashCode() %7B%0A        return upCommit.hashCode() + downCommit.hashCode();%0A    %7D%0A%0A    @Override%0A    public boolean equals(Object obj) %7B%0A        if (obj != null && obj.getClass() == Branch.class) %7B%0A            Branch anBranch = (Branch) obj;%0A            return anBranch.upCommit == upCommit && anBranch.downCommit == downCommit;%0A        %7D%0A        return false;%0A    %7D%0A%0A
     @Overrid

fix Branch equals & hashCode