package com.kii.thingif.query;

import android.os.Parcel;
import android.os.Parcelable;

import com.kii.thingif.trigger.clause.Clause;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.Date;

public class TimeRange implements Parcelable{

    private Date lowerLimit;
    private Date upperLimit;

    public TimeRange(Date lowerLimit, Date upperLimit) {
        this.lowerLimit = lowerLimit;
        this.upperLimit = upperLimit;
    }

    public JSONObject toJSONObject() {
        JSONObject ret = new JSONObject();
        try {
            ret.put("type", "withinTimeRange");
            ret.put("lowerLimit", this.lowerLimit.getTime());
            ret.put("upperLimit", this.upperLimit.getTime());
            return ret;
        } catch (JSONException e) {
            // Won't happens.
            throw new RuntimeException(e);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(this.lowerLimit.getTime());
        dest.writeLong(this.upperLimit.getTime());
    }

    public TimeRange(Parcel in) {
        this.lowerLimit = new Date(in.readLong());
        this.upperLimit = new Date(in.readLong());
    }

    public static final Creator<TimeRange> CREATOR = new Creator<TimeRange>() {
        @Override
        public TimeRange createFromParcel(Parcel source) {
            return new TimeRange(source);
        }

        @Override
        public TimeRange[] newArray(int size) {
            return new TimeRange[size];
        }
    };
}
@@ -80,16 +80,59 @@
 celable;
+%0Aimport android.support.annotation.NonNull;
 %0A%0Aimport
@@ -311,24 +311,33 @@
     private 
+@NonNull 
 Date lowerLi
@@ -353,16 +353,25 @@
 private 
+@NonNull 
 Date upp
@@ -405,24 +405,67 @@
 nge(
-Date lowerLimit,
+%0A            @NonNull Date lowerLimit,%0A            @NonNull
  Dat

Add nullable/nonnullable annotation in TimeRange