package com.atlassian.bitbucket.mesh.git;

import javax.annotation.Nonnull;

import static java.util.Objects.requireNonNull;

public class GitObjectInfo {

    private final String objectId;
    private final long size;
    private final GitObjectType type;

    public GitObjectInfo(@Nonnull String objectId, long size, @Nonnull GitObjectType type) {
        this.objectId = requireNonNull(objectId, "objectId");
        this.size = size;
        this.type = requireNonNull(type, "type");
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        GitObjectInfo that = (GitObjectInfo) o;
        return objectId.equals(that.objectId);
    }

    @Nonnull
    public String getObjectId() {
        return objectId;
    }

    public long getSize() {
        return size;
    }

    @Nonnull
    public GitObjectType getType() {
        return type;
    }

    @Override
    public int hashCode() {
        return objectId.hashCode();
    }
}
