[LIB-8] Add EventFormat to the Event entity
[snooker-score-api.git] / src / main / java / org / hedgecode / snooker / json / JsonEvent.java
index 2f47ee4..0ba62ab 100644 (file)
@@ -22,6 +22,7 @@ import com.google.gson.annotations.Expose;
 import com.google.gson.annotations.SerializedName;
 
 import org.hedgecode.snooker.api.Event;
+import org.hedgecode.snooker.api.EventFormat;
 import org.hedgecode.snooker.api.Season;
 
 /**
@@ -85,6 +86,8 @@ public class JsonEvent extends JsonIdEntity implements Event {
     private boolean team;
     @SerializedName("Format")
     private int format;
+    @Expose
+    private EventFormat formatType;
     @SerializedName("Twitter")
     private String twitter;
     @SerializedName("HashTag")
@@ -112,6 +115,9 @@ public class JsonEvent extends JsonIdEntity implements Event {
     @SerializedName("PreviousEdition")
     private int previousEdition;
 
+    protected JsonEvent() {
+    }
+
     @Override
     public int eventId() {
         return eventId;
@@ -124,12 +130,16 @@ public class JsonEvent extends JsonIdEntity implements Event {
 
     @Override
     public Date startDate() {
-        return startDate;
+        return startDate == null
+                ? null
+                : new Date(startDate.getTime());
     }
 
     @Override
     public Date endDate() {
-        return endDate;
+        return endDate == null
+                ? null
+                : new Date(endDate.getTime());
     }
 
     @Override
@@ -252,6 +262,13 @@ public class JsonEvent extends JsonIdEntity implements Event {
     }
 
     @Override
+    public EventFormat formatType() {
+        if (formatType == null)
+            formatType = EventFormat.byNumber(format);
+        return formatType;
+    }
+
+    @Override
     public String twitter() {
         return twitter;
     }