package com.orgsync.api.model.events;

import java.util.Date;

/**
 * Information about a single occurence of an event.
 * 
 * @author steffyj
 * 
 */
public class EventOccurrence {

    // TODO blows up for allDay events... not full dates
    private Date startsAt;
    private Date endsAt;
    private boolean isAllDay;

    public final Date getStartsAt() {
        return startsAt;
    }

    public final Date getEndsAt() {
        return endsAt;
    }

    public final boolean isAllDay() {
        return isAllDay;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((endsAt == null) ? 0 : endsAt.hashCode());
        result = prime * result + (isAllDay ? 1231 : 1237);
        result = prime * result + ((startsAt == null) ? 0 : startsAt.hashCode());
        return result;
    }

    @Override
    public boolean equals(final Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        EventOccurrence other = (EventOccurrence) obj;
        if (endsAt == null) {
            if (other.endsAt != null)
                return false;
        } else if (!endsAt.equals(other.endsAt))
            return false;
        if (isAllDay != other.isAllDay)
            return false;
        if (startsAt == null) {
            if (other.startsAt != null)
                return false;
        } else if (!startsAt.equals(other.startsAt))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "EventOcurrence [startsAt=" + startsAt + ", endAt=" + endsAt + ", isAllDay=" + isAllDay + "]";
    }

}

@@ -36,31 +36,8 @@
 s;%0A%0A
-import java.util.Date;%0A
 %0A/**
@@ -161,77 +161,22 @@
     
-// TODO blows up for allDay events... not full dates%0A    private Date
+private String
  sta
@@ -194,20 +194,22 @@
 private 
-Date
+String
  endsAt;
@@ -253,28 +253,30 @@
 ublic final 
-Date
+String
  getStartsAt
@@ -333,12 +333,14 @@
 nal 
-Date
+String
  get
@@ -1596,16 +1596,17 @@
 %22EventOc
+c
 urrence 
@@ -1636,16 +1636,17 @@
 + %22, end
+s
 At=%22 + e

Change EventOccurrence to use String instead of Date for staging and end times, since it can be either a "yyyy-MM-dd" or full UTC string... In the future it would better if we can use some custom deserializer to handle this. Either some type that handles both types or have fields for each type and only one set of fields is present at a time.