class DateExtractionHelper {

    public static <T extends ExtractedDate> List<List<T>> cluster(List<T> dates, DateExactness compareDepth) {
        List<List<T>> clusters = new ArrayList<List<T>>();
        DateComparator dc = new DateComparator(compareDepth);
        for (T date : dates) {
            boolean sameDatestamp = false;
            for (int resultIndex = 0; resultIndex < clusters.size(); resultIndex++) {
                T firstDate = clusters.get(resultIndex).get(0);
                int compare = dc.compare(firstDate, date);
                if (compare == 0) {
                    clusters.get(resultIndex).add(date);
                    sameDatestamp = true;
                    break;
                }
            }
            if (!sameDatestamp) {
                List<T> newDate = new ArrayList<T>();
                newDate.add(date);
                clusters.add(newDate);
            }
        }
        return clusters;
    }

    private  DateExtractionHelper();

}