package com.atlassian.bitbucket.internal.mirroring.repositories;

import com.atlassian.bitbucket.repository.Ref;
import com.atlassian.bitbucket.repository.RefType;
import com.atlassian.bitbucket.repository.StandardRefType;

import javax.annotation.Nonnull;

public class TestRef implements Ref {

    private final String id;
    private final String hash;

    public TestRef(String id, String hash) {
        this.id = id;
        this.hash = hash;
    }

    @Nonnull
    @Override
    public String getLatestCommit() {
        return hash;
    }

    @Nonnull
    @Override
    public String getDisplayId() {
        return id;
    }

    @Nonnull
    @Override
    public String getId() {
        return id;
    }

    @Nonnull
    @Override
    public RefType getType() {
        return id != null && id.startsWith("refs/tags/") ? StandardRefType.TAG : StandardRefType.BRANCH;
    }
}
