Gitlet / gitlet / Branch.java
Branch.java
Raw
package gitlet;

import java.io.Serial;
import java.io.Serializable;

public class Branch implements Serializable {


    @Serial
    private static final long serialVersionUID = 1234567L;


    /**
     * The name of the branch.
     */
    private final String branchName;


    /**
     * The SHA-1 string of the commit object that this branch points to.
     */
    private String commitSHA;


    public Branch (String branchName, String commitSHA) {
        this.branchName = branchName;
        this.commitSHA = commitSHA;
    }

    public String getBranchName(){
        return this.branchName;
    }

    public String getCommitSHA() {
        return this.commitSHA;
    }

    public void updateCommitSHA(String newCommitSHA) {
        this.commitSHA = newCommitSHA;
    }

    @Override
    public String toString() {
        return String.format("BranchName:%s, CommitReference:%s", this.getBranchName(), this.getCommitSHA());
    }
}