package de.ivu.elect.jee.database;

import java.io.Serializable;
import java.util.Map;


import static de.ivu.elect.jee.database.DatabaseStatistikData.getLongValue;

public class DatabaseTimeData implements Serializable {

  private static final long serialVersionUID = 1L;

  private final long averageBlockingTime;

  private final long averageCreationTime;

  private final long averageGetTime;

  private final long averageUsageTime;

  private final long maxCreationTime;

  private final long maxGetTime;

  private final long maxUsageTime;

  private final long maxWaitTime;

  public DatabaseTimeData(Map<String, Object> attributeMap) {
    averageBlockingTime = getLongValue(attributeMap, "AverageBlockingTime");
    averageCreationTime = getLongValue(attributeMap, "AverageCreationTime");
    averageGetTime = getLongValue(attributeMap, "AverageGetTime");
    averageUsageTime = getLongValue(attributeMap, "AverageUsageTime");
    maxCreationTime = getLongValue(attributeMap, "MaxCreationTime");
    maxGetTime = getLongValue(attributeMap, "MaxGetTime");
    maxUsageTime = getLongValue(attributeMap, "MaxUsageTime");
    maxWaitTime = getLongValue(attributeMap, "MaxWaitTime");
  }

  public long getAverageBlockingTime() {
    return averageBlockingTime;
  }

  public long getAverageCreationTime() {
    return averageCreationTime;
  }

  public long getAverageGetTime() {
    return averageGetTime;
  }

  public long getAverageUsageTime() {
    return averageUsageTime;
  }

  public long getMaxCreationTime() {
    return maxCreationTime;
  }

  public long getMaxGetTime() {
    return maxGetTime;
  }

  public long getMaxUsageTime() {
    return maxUsageTime;
  }

  public long getMaxWaitTime() {
    return maxWaitTime;
  }

  @Override
  public String toString() {
    return "DatabaseTimeData{" +
        "averageBlockingTime=" + averageBlockingTime +
        ", averageCreationTime=" + averageCreationTime +
        ", averageGetTime=" + averageGetTime +
        ", averageUsageTime=" + averageUsageTime +
        ", maxCreationTime=" + maxCreationTime +
        ", maxGetTime=" + maxGetTime +
        ", maxUsageTime=" + maxUsageTime +
        ", maxWaitTime=" + maxWaitTime +
        '}';
  }
}
