package com.atlassian.stash.internal.scm.git.command.lsfiles;

import com.atlassian.bitbucket.content.Path;

import javax.annotation.Nonnull;
import java.util.Objects;

public class StagedFile {

    private final String contentId;
    private final Path path;
    private final int stage;

    public StagedFile(String contentId, Path path, int stage) {
        this.contentId = contentId;
        this.path = path;
        this.stage = stage;
    }

    @Nonnull
    public String getContentId() {
        return contentId;
    }

    @Nonnull
    public Path getPath() {
        return path;
    }

    public int getStage() {
        return stage;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o instanceof StagedFile) {
            StagedFile d = (StagedFile) o;

            return Objects.equals(getPath(), d.getPath()) &&
                    Objects.equals(getContentId(), d.getContentId())
                    && getStage() == d.getStage();
        }
        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(getPath(), getContentId(), getStage());
    }
}
