package de.ivu.elect.business.system.entity;

import static java.util.Arrays.asList;

public class HibernateCollectionStatistik {

  private final String name;

  public HibernateCollectionStatistik(String name) {
    this.name = name;
  }

  public String getName() {
    return name;
  }

  public long getUpdateCount() {
    return 0;
  }

  /**
   * "the fetch counter only gets incremented when the entity is retrieved from the datasource (as opposed to any
   * caches)"
   * <p/>
   * http://stackoverflow.com/questions/609351/in-hibernate-statistics-whats-the-difference-between-load-and-fetch
   */
  public long getFetchCount() {
    return 0;
  }

  /**
   * "The load counter gets incremented any time the entity gets loaded, whether from the datasource or the caches."
   * <p/>
   * http://stackoverflow.com/questions/609351/in-hibernate-statistics-whats-the-difference-between-load-and-fetch
   */
  public long getLoadCount() {
    return 0;
  }

  public long getRemoveCount() {
    return 0;
  }

  public long getRecreateCount() {
    return 0;
  }

  public boolean isWertVorhanden() {
    return getUpdateCount()>0 ||getFetchCount()>0 || getLoadCount()>0||getRemoveCount()>0||getRecreateCount()>0;
  }

  @Override
  public String toString() {
    return "|" + String.join("|", asList(getName(), Long.toString(getFetchCount()), Long.toString(getLoadCount()), Long.toString(getRecreateCount()),
        Long.toString(getUpdateCount()), Long.toString(getRecreateCount())))+"|";
  }

  public static String toStringHeader() {
    return "||" + String.join("||",
        asList("Name", "Fetches", "Loads", "Recreates", "Updates", "Removes"))+"||";
  }

}
