package com.pennapps.labs.pennmobile.classes;

import com.google.gson.annotations.SerializedName;

import org.joda.time.DateTime;
import org.joda.time.Interval;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by Adel on 12/16/14.
 * Class for Dining Venues from Business Services API
 */
public class Venue {
    public int id;
    public String name;
    public String venueType;
    @SerializedName("dateHours") public List<VenueInterval> hours = new ArrayList<>();

    /**
     * Indicates whether a dining hall is residential (as opposed to retail).
     * @return boolean of whether a dining hall is labeled as residential
     */
    public boolean isResidential() {
        return venueType.equals("residential") && !name.equals("Cafe at McClelland");
    }

    /**
     * Get a mapping of meal names to open hours for all meals in the dining hall this week
     * @return HashMap of meal name (lunch, dinner) to open hours expressed as a Joda Interval
     */
    public HashMap<String, Interval> getHours() {
        DateTime currentTime = new DateTime();
        // Split by T gets the Y-M-D format to compare against the date in JSON
        for (VenueInterval interval : hours) {
            if (interval.date.equals(currentTime.toString().split("T")[0])) {
                return interval.getIntervals();
            }
        }

        return new HashMap<>();
    }
}

@@ -231,16 +231,38 @@
 il.List;
+%0Aimport java.util.Map;
 %0A%0A/**%0A *
@@ -1220,172 +1220,794 @@
     
-for (VenueInterval interval : hours) %7B%0A            if (interval.date.equals(currentTime.toString().split(%22T%22)%5B0%5D)) %7B%0A                return interval.getIntervals();
+DateTime tomorrow = currentTime.plusDays(1);%0A        HashMap%3CString, Interval%3E intervals = new HashMap%3C%3E();%0A        for (VenueInterval interval : hours) %7B%0A            if (interval.date.equals(tomorrow.toString().split(%22T%22)%5B0%5D)) %7B%0A                intervals.putAll(interval.getIntervals());%0A            %7D%0A        %7D%0A        for (VenueInterval interval : hours) %7B%0A            if (interval.date.equals(currentTime.toString().split(%22T%22)%5B0%5D)) %7B%0A                for(Map.Entry%3CString, Interval%3E entry: interval.getIntervals().entrySet())%7B%0A                    if(entry.getValue().contains(currentTime)%7C%7C%0A                            currentTime.isBefore(entry.getValue().getStart()))%7B%0A                        intervals.put(entry.getKey(), entry.getValue());%0A                    %7D%0A                %7D
 %0A   
@@ -2043,31 +2043,25 @@
  return 
-new HashMap%3C%3E()
+intervals
 ;%0A    %7D%0A

Fix #263