package net.dean.jraw.models;

import com.google.auto.value.AutoValue;
import com.squareup.moshi.Json;
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.Moshi;
import net.dean.jraw.databind.RedditModel;
import net.dean.jraw.databind.UnixTime;
import org.jetbrains.annotations.NotNull;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@AutoValue
@RedditModel
public abstract class LiveUpdate implements Created, Identifiable, Serializable {
    public abstract String getAuthor();
    public abstract String getBody();

    @NotNull
    @Override
    @Json(name = "created_utc") @UnixTime public abstract Date getCreated();

    @NotNull
    @Json(name = "name") public abstract String getFullName();

    public abstract List<Embed> getEmbeds();

    /**
     * If the update has been stricken. A stricken update appears on the website with the <strike>strikethrough</strike>
     * effect applied to its body.
     */
    public abstract boolean isStricken();

    public static JsonAdapter<LiveUpdate> jsonAdapter(Moshi moshi) {
        return new AutoValue_LiveUpdate.MoshiJsonAdapter(moshi);
    }

    /** Embedded media inside of a live update. */
    @AutoValue
    public static abstract class Embed implements Serializable {
        public abstract String getUrl();
        public abstract int getWidth();
        public abstract int getHeight();

        public static JsonAdapter<Embed> jsonAdapter(Moshi moshi) {
            return new AutoValue_LiveUpdate_Embed.MoshiJsonAdapter(moshi);
        }
    }
}

@@ -292,16 +292,59 @@
 NotNull;
+%0Aimport org.jetbrains.annotations.Nullable;
 %0A%0Aimport
@@ -1361,32 +1361,42 @@
 %0A        public 
+@Nullable 
 abstract int get
@@ -1384,27 +1384,31 @@
 le abstract 
-i
+I
 nt
+eger
  getWidth();
@@ -1415,32 +1415,42 @@
 %0A        public 
+@Nullable 
 abstract int get
@@ -1446,11 +1446,15 @@
 act 
-i
+I
 nt
+eger
  get

Fix #247