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

import java.util.List;

import de.ivu.elect.jee.performance.ViewAccessTarget;
import de.ivu.elect.jee.performance.ViewAccessTargetStatistics;
import de.ivu.elect.jee.performance.ViewAccessType;


import static java.util.stream.Collectors.toList;

public enum PerformanceStatistikViewAccessType {

  GRUPPIERT {
    @Override
    public List<ViewAccessTargetStatistics> filterGruppiere(List<ViewAccessTargetStatistics> statistics) {
      return ViewAccessTargetStatistics.gruppiere(statistics, original -> ViewAccessTarget.copyNewAccessType(original, ViewAccessType.GESAMT));
    }
  },
  GETRENNT {
    @Override
    public List<ViewAccessTargetStatistics> filterGruppiere(List<ViewAccessTargetStatistics> statistics) {
      return statistics;
    }
  },
  GET {
    @Override
    public List<ViewAccessTargetStatistics> filterGruppiere(List<ViewAccessTargetStatistics> statistics) {
      return statistics.stream().filter(s -> ViewAccessType.GET.equals(s.getAccessType())).collect(toList());
    }
  },
  POST {
    @Override
    public List<ViewAccessTargetStatistics> filterGruppiere(List<ViewAccessTargetStatistics> statistics) {
      return statistics.stream().filter(s -> ViewAccessType.POST.equals(s.getAccessType())).collect(toList());
    }
  },
  AJAX {
    @Override
    public List<ViewAccessTargetStatistics> filterGruppiere(List<ViewAccessTargetStatistics> statistics) {
      return statistics.stream().filter(s -> ViewAccessType.AJAX.equals(s.getAccessType())).collect(toList());
    }
  },;

  public abstract List<ViewAccessTargetStatistics> filterGruppiere(List<ViewAccessTargetStatistics> statistics);


}
