<commit_before>package org.hanuna.gitalk.commitmodel.builder;

import org.hanuna.gitalk.commitmodel.Commit;
import org.hanuna.gitalk.commitmodel.CommitData;
import org.hanuna.gitalk.commitmodel.Hash;
import org.hanuna.gitalk.common.ReadOnlyList;
import org.hanuna.gitalk.common.SimpleReadOnlyList;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

/**
 * @author erokhins
 */
class MutableCommit implements Commit {
    private final Hash hash;
    private boolean wasRead = false;
    private ReadOnlyList<Commit> parents;
    private List<Commit> childrens = new ArrayList<Commit>(1);
    private String author;
    private String message;
    private long timeStamp;
    private int index = -1;

    public MutableCommit(Hash hash) {
        this.hash = hash;
    }

    public void addChildren(Commit children) {
        childrens.add(children);
    }

    public void set(@NotNull CommitData data, @NotNull ReadOnlyList<Commit> parents, int index) {
        assert !wasRead : "double set commit data";
        wasRead = true;
        this.parents = parents;
        this.author = data.getAuthor();
        this.message = data.getCommitMessage();
        this.timeStamp = data.getTimeStamp();
        this.index = index;
    }


    @NotNull
    @Override
    public Hash hash() {
        return hash;
    }

    @Override
    public boolean wasRead() {
        return wasRead;
    }

    @NotNull
    @Override
    public ReadOnlyList<Commit> getParents() {
        return parents;
    }

    @NotNull
    @Override
    public ReadOnlyList<Commit> getChildren() {
        return new SimpleReadOnlyList<Commit>(childrens);
    }

    @NotNull
    @Override
    public String getMessage() {
        return message;
    }

    @NotNull
    @Override
    public String getAuthor() {
        return author;
    }

    @Override
    public long getTimeStamp() {
        return timeStamp;
    }


    public boolean equals(Object obj) {
        if (obj instanceof Commit) {
            return ((Commit) obj).hash().equals(hash);
        }
        return false;
    }

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

    @Override
    public int index() {
        assert !wasRead : "index undefined";
        return index;
    }

}<commit_msg>fix bug with assert readed commit<commit_after>package org.hanuna.gitalk.commitmodel.builder;

import org.hanuna.gitalk.commitmodel.Commit;
import org.hanuna.gitalk.commitmodel.CommitData;
import org.hanuna.gitalk.commitmodel.Hash;
import org.hanuna.gitalk.common.ReadOnlyList;
import org.hanuna.gitalk.common.SimpleReadOnlyList;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

/**
 * @author erokhins
 */
class MutableCommit implements Commit {
    private final Hash hash;
    private boolean wasRead = false;
    private ReadOnlyList<Commit> parents;
    private List<Commit> childrens = new ArrayList<Commit>(1);
    private String author;
    private String message;
    private long timeStamp;
    private int index = -1;

    public MutableCommit(Hash hash) {
        this.hash = hash;
    }

    public void addChildren(Commit children) {
        childrens.add(children);
    }

    public void set(@NotNull CommitData data, @NotNull ReadOnlyList<Commit> parents, int index) {
        assert !wasRead : "double set commit data";
        wasRead = true;
        this.parents = parents;
        this.author = data.getAuthor();
        this.message = data.getCommitMessage();
        this.timeStamp = data.getTimeStamp();
        this.index = index;
    }


    @NotNull
    @Override
    public Hash hash() {
        return hash;
    }

    @Override
    public boolean wasRead() {
        return wasRead;
    }

    @NotNull
    @Override
    public ReadOnlyList<Commit> getParents() {
        return parents;
    }

    @NotNull
    @Override
    public ReadOnlyList<Commit> getChildren() {
        return new SimpleReadOnlyList<Commit>(childrens);
    }

    @NotNull
    @Override
    public String getMessage() {
        return message;
    }

    @NotNull
    @Override
    public String getAuthor() {
        return author;
    }

    @Override
    public long getTimeStamp() {
        return timeStamp;
    }


    public boolean equals(Object obj) {
        if (obj instanceof Commit) {
            return ((Commit) obj).hash().equals(hash);
        }
        return false;
    }

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

    @Override
    public int index() {
        assert wasRead : "index undefined";
        return index;
    }

}
{'fraction_non_alphanumeric': 0.09559613319011816, 'fraction_numerical': 0.0008592910848549946, 'mean_word_length': 2.51131221719457, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7057846', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1342, 'n_words': 341}