package com.atlassian.bitbucket.repository;

import com.atlassian.bitbucket.event.repository.RepositoryRefsChangedEvent;

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

/**
 * Represents a ref change, used mainly by {@link RepositoryRefsChangedEvent}.
 */
public interface RefChange {

    /**
     * @deprecated in 4.0 for removal in 5.0. With Java 8, {@code RefChange::getRefId} can be used instead.
     */
    @Deprecated
    Function<RefChange, String> TO_REF_ID = RefChange::getRefId;

    /**
     * @deprecated in 4.0 for removal in 5.0. With Java 8, {@code RefChange::getType} can be used instead.
     */
    @Deprecated
    Function<RefChange, RefChangeType> TO_TYPE = RefChange::getType;

    /**
     * @return the ref that has been updated
     */
    @Nonnull
    MinimalRef getRef();

    /**
     * @return the ref that has been updated
     * @deprecated in 4.0 for removal in 5.0. Use {@link #getRef()} instead
     */
    @Deprecated
    @Nonnull
    String getRefId();

    /**
     * @return the previous hash
     */
    @Nonnull
    String getFromHash();

    /**
     * @return the new hash
     */
    @Nonnull
    String getToHash();

    /**
     * @return the type of ref change
     */
    @Nonnull
    RefChangeType getType();
}
