package com.atlassian.bitbucket.repository;

import com.atlassian.bitbucket.commit.Commit;

import javax.annotation.Nonnull;
import java.util.function.Function;

/**
 * Common abstraction between reference types like {@link Branch branches} and {@link Tag tags}.
 */
public interface Ref extends MinimalRef {

    /**
     * Retrieve the {@link #getLatestCommit latest commit} to this ref.
     *
     * @see #getLatestCommit()
     * @deprecated in 4.0 for removal in 5.0. With Java 8, {@code Ref::getLatestCommit} can be used instead.
     */
    @Deprecated
    Function<Ref, String> TO_LATEST_COMMIT = Ref::getLatestCommit;

    /**
     * The {@link Commit#getId ID} of the commit at the tip of this ref.
     *
     * @return the tip commit's ID
     */
    @Nonnull
    String getLatestCommit();
}
