// Path: github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/head/GitHubBranchSCMHead.java
// public class GitHubBranchSCMHead extends GitHubSCMHead<GitHubBranchCause> {
//     private static final long serialVersionUID = 1L;
// 
//     public GitHubBranchSCMHead(@NonNull String name, String sourceId) {
//         super(name, sourceId);
//     }
// 
//     @Override
//     public String getPronoun() {
//         return "Branch " + getName();
//     }
// 
//     @Override
//     public String fetchHeadSha(GHRepository remoteRepo) throws IOException {
//         GHBranch branch = remoteRepo.getBranch(getName());
//         if (branch == null) {
//             throw new IOException("No branch " + getName() + " in " + remoteRepo.getFullName());
//         }
//         return branch.getSHA1();
//     }
// 
//     @Override
//     public String getHeadSha(GitHubBranchCause cause) {
//         return cause.getCommitSha();
//     }
// }


import com.github.kostyasha.github.integration.branch.webhook.BranchInfo;
import com.github.kostyasha.github.integration.multibranch.head.GitHubBranchSCMHead;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMRevision;
import jenkins.scm.api.SCMSource;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Collections;
import java.util.Map;
package com.github.kostyasha.github.integration.multibranch.hooks;



/**
 * @author Kanstantsin Shautsou
 */
public class GitHubBranchSCMHeadEvent extends GitHubScmHeadEvent<BranchInfo> {
    public GitHubBranchSCMHeadEvent(@NonNull Type type, long timestamp, @NonNull BranchInfo payload, @CheckForNull String origin) {
        super(type, timestamp, payload, origin);
    }

    @NonNull
    @Override
    protected String getSourceRepo() {
        return getPayload().getRepo();
    }

    @NonNull
    @Override
    public Map<SCMHead, SCMRevision> heads(@NonNull SCMSource source) {
        if (!isMatch(source)) {
            return Collections.emptyMap();
        }
// Path: github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/head/GitHubBranchSCMHead.java
// public class GitHubBranchSCMHead extends GitHubSCMHead<GitHubBranchCause> {
//     private static final long serialVersionUID = 1L;
// 
//     public GitHubBranchSCMHead(@NonNull String name, String sourceId) {
//         super(name, sourceId);
//     }
// 
//     @Override
//     public String getPronoun() {
//         return "Branch " + getName();
//     }
// 
//     @Override
//     public String fetchHeadSha(GHRepository remoteRepo) throws IOException {
//         GHBranch branch = remoteRepo.getBranch(getName());
//         if (branch == null) {
//             throw new IOException("No branch " + getName() + " in " + remoteRepo.getFullName());
//         }
//         return branch.getSHA1();
//     }
// 
//     @Override
//     public String getHeadSha(GitHubBranchCause cause) {
//         return cause.getCommitSha();
//     }
// }


// Path: github-pullrequest-plugin/src/main/java/com/github/kostyasha/github/integration/multibranch/hooks/GitHubBranchSCMHeadEvent.java
import com.github.kostyasha.github.integration.branch.webhook.BranchInfo;
import com.github.kostyasha.github.integration.multibranch.head.GitHubBranchSCMHead;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMRevision;
import jenkins.scm.api.SCMSource;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Collections;
import java.util.Map;

package com.github.kostyasha.github.integration.multibranch.hooks;



/**
 * @author Kanstantsin Shautsou
 */
public class GitHubBranchSCMHeadEvent extends GitHubScmHeadEvent<BranchInfo> {
    public GitHubBranchSCMHeadEvent(@NonNull Type type, long timestamp, @NonNull BranchInfo payload, @CheckForNull String origin) {
        super(type, timestamp, payload, origin);
    }

    @NonNull
    @Override
    protected String getSourceRepo() {
        return getPayload().getRepo();
    }

    @NonNull
    @Override
    public Map<SCMHead, SCMRevision> heads(@NonNull SCMSource source) {
        if (!isMatch(source)) {
            return Collections.emptyMap();
        }
        return Collections.singletonMap(new GitHubBranchSCMHead(getPayload().getBranchName(), source.getId()), null);