package info.knacki.pass.git.entities;

import info.knacki.pass.git.GitSha1;
import info.knacki.pass.io.CharsetHelper;

public class GitPackableFactory {
    public static GitPackable build(GitPackable.eType type, String hash, byte[] data) {
        switch (type) {
            case eType_Commit:
                return new GitCommit(hash, CharsetHelper.ByteArrayToString(data));

            case eType_Tree:
                GitObject.GitTree tree = new GitObject.GitTree(GitSha1.StringToBytes(hash));
                tree.Initialize().Fill(data);
                return tree;

            case eType_Blob:
                return new GitObject.GitRawData(GitSha1.StringToBytes(hash), data);

            case eType_OfsDelta:
            case eType_RefDelta:
            case eType_Tag:
                break;
        }
        return null;
    }
}
