class Range implements Serializable {

    public static List<Range> normalize(List<Range> ranges)
    {
        List<Range> newRanges = new ArrayList<>();
        List<IMSTimePoint> imsTimePoints = IMSTimePoint.build(ranges);
        TreeSet<IMSTimePoint> imsTimePointTreeSet = new TreeSet<>(imsTimePoints);
        Iterator<IMSTimePoint> it = imsTimePointTreeSet.iterator();
        String day = "";
        int sh = -1;
        int eh = -1;
        while (it.hasNext())
        {
            IMSTimePoint imsTimePoint = it.next();
            if (!day.equals(imsTimePoint.getDate()) && !day.equals(""))
            {
                Range newRange = new Range();
                newRange.st = day;
                newRange.ed = day;
                newRange.sh = String.valueOf(sh);
                newRange.eh = String.valueOf(eh);
                newRanges.add(newRange);
                day = "";
                sh = -1;
            }
            if (day.equals(""))
            {
                day = imsTimePoint.getDate();
            }
            if (sh == -1)
            {
                sh = imsTimePoint.getHourIndex();
            }
            eh = imsTimePoint.getHourIndex();
        }

        if (((newRanges.size() > 0 && !day.equals(newRanges.get(newRanges.size() - 1).getSt())) || (newRanges.size() == 0)) && !day.equals(""))
        {
            Range newRange = new Range();
            newRange.st = day;
            newRange.ed = day;
            newRange.sh = String.valueOf(sh);
            newRange.eh = String.valueOf(eh);
            newRanges.add(newRange);
        }

        return newRanges;
    }

    public  Range();
    public  Range(String st, String ed, String sh, String eh);

}