<commit_before>package org.smoothbuild.record.spec;

import java.util.Objects;

import org.smoothbuild.db.hashed.Hash;
import org.smoothbuild.db.hashed.HashedDb;
import org.smoothbuild.record.base.MerkleRoot;
import org.smoothbuild.record.base.Record;
import org.smoothbuild.record.base.RecordImpl;
import org.smoothbuild.record.db.RecordDb;

public abstract class Spec implements Record {
  private final SpecKind kind;
  private final RecordImpl record;
  protected final HashedDb hashedDb;
  protected final RecordDb recordDb;

  protected Spec(MerkleRoot merkleRoot, SpecKind kind, HashedDb hashedDb,
      RecordDb recordDb) {
    this.kind = kind;
    this.record = new RecordImpl(merkleRoot, hashedDb);
    this.hashedDb = hashedDb;
    this.recordDb = recordDb;
  }

  /**
   * Creates new java object Record represented by merkleRoot.
   */
  public abstract Record newJObject(MerkleRoot merkleRoot);

  @Override
  public Hash hash() {
    return record.hash();
  }

  @Override
  public Hash dataHash() {
    return record.dataHash();
  }

  @Override
  public Spec spec() {
    return record.spec();
  }

  @Override
  public boolean equals(Object object) {
    return (object instanceof Spec that) && Objects.equals(hash(), that.hash());
  }

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

  @Override
  public String toString() {
    return valueToString() + ":" + hash();
  }

  @Override
  public String valueToString() {
    return name();
  }

  public String name() {
    return kind.name();
  }

  public SpecKind kind() {
    return kind;
  }
<commit_msg>refactored Spec to use MerkleRoot directly instead of wrapping it with RecordImpl<commit_after>package org.smoothbuild.record.spec;

import java.util.Objects;

import org.smoothbuild.db.hashed.Hash;
import org.smoothbuild.db.hashed.HashedDb;
import org.smoothbuild.record.base.MerkleRoot;
import org.smoothbuild.record.base.Record;
import org.smoothbuild.record.db.RecordDb;

public abstract class Spec implements Record {
  private final MerkleRoot merkleRoot;
  private final SpecKind kind;
  protected final HashedDb hashedDb;
  protected final RecordDb recordDb;

  protected Spec(MerkleRoot merkleRoot, SpecKind kind, HashedDb hashedDb, RecordDb recordDb) {
    this.merkleRoot = merkleRoot;
    this.kind = kind;
    this.hashedDb = hashedDb;
    this.recordDb = recordDb;
  }

  /**
   * Creates new java object Record represented by merkleRoot.
   */
  public abstract Record newJObject(MerkleRoot merkleRoot);

  @Override
  public Hash hash() {
    return merkleRoot.hash();
  }

  @Override
  public Hash dataHash() {
    return merkleRoot.dataHash();
  }

  @Override
  public Spec spec() {
    return merkleRoot.spec();
  }

  @Override
  public boolean equals(Object object) {
    return (object instanceof Spec that) && Objects.equals(hash(), that.hash());
  }

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

  @Override
  public String toString() {
    return valueToString() + ":" + hash();
  }

  @Override
  public String valueToString() {
    return name();
  }

  public String name() {
    return kind.name();
  }

  public SpecKind kind() {
    return kind;
  }

{'fraction_non_alphanumeric': 0.1033302209772798, 'fraction_numerical': 0.0, 'mean_word_length': 3.6311239193083575, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '6197029', 'n_tokens_mistral': 1012, 'n_tokens_neox': 990, 'n_words': 265}