package com.kii.thingif.clause.trigger;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.kii.thingif.clause.base.BaseRange;

import org.json.JSONObject;

public class RangeClauseInTrigger implements BaseRange, TriggerClause {
    private @NonNull String field;
    private @Nullable Long upperLimit;
    private @Nullable Long lowerLimit;
    private @Nullable Boolean upperIncluded;
    private @Nullable Boolean lowerIncluded;


    private RangeClauseInTrigger(
            @NonNull String field,
            @Nullable Long upperLimit,
            @Nullable Boolean upperIncluded,
            @Nullable Long lowerLimit,
            @Nullable Boolean lowerIncluded) {
        this.field = field;
        this.upperIncluded = upperIncluded;
        this.upperLimit = upperLimit;
        this.lowerIncluded = lowerIncluded;
        this.lowerLimit = lowerLimit;
    }
    public static RangeClauseInTrigger range(
            @NonNull String field,
            @NonNull Number upperLimit,
            @NonNull Boolean upperIncluded,
            @NonNull Number lowerLimit,
            @NonNull Boolean lowerIncluded) {
        return new RangeClauseInTrigger(
                field,
                upperLimit.longValue(),
                upperIncluded,
                lowerLimit.longValue(),
                lowerIncluded);
    }
    public static RangeClauseInTrigger greaterThan(
            @NonNull String field,
            @NonNull Number lowerLimit) {
        return new RangeClauseInTrigger(
                field,
                null,
                null,
                lowerLimit.longValue(),
                Boolean.FALSE);
    }
    public static RangeClauseInTrigger greaterThanEquals(
            @NonNull String field,
            @NonNull Number lowerLimit) {
        return new RangeClauseInTrigger(
                field,
                null,
                null,
                lowerLimit.longValue(),
                Boolean.TRUE);
    }
    public static RangeClauseInTrigger lessThan(
            @NonNull String field,
            @NonNull Number upperLimit) {
        return new RangeClauseInTrigger(
                field,
                upperLimit.longValue(),
                Boolean.FALSE,
                null,
                null);
    }
    public static RangeClauseInTrigger lessThanEquals(
            @NonNull String field,
            @NonNull Number upperLimit) {
        return new RangeClauseInTrigger(
                field,
                upperLimit.longValue(),
                Boolean.TRUE,
                null,
                null);
    }

    @Override
    @NonNull
    public String getField() {
        return this.field;
    }

    @Override
    @Nullable
    public Boolean getLowerIncluded() {
        return this.lowerIncluded;
    }

    @Override
    @Nullable
    public Long getUpperLimit() {
        return this.upperLimit;
    }

    @Override
    @Nullable
    public Long getLowerLimit() {
        return this.lowerLimit;
    }

    @Override
    @Nullable
    public Boolean getUpperIncluded() {
        return this.upperIncluded;
    }

    @Override
    public JSONObject toJSONObject() {
        //TODO: implement me
        return null;
    }
}

@@ -270,16 +270,51 @@
 lause %7B%0A
+    private @NonNull String alias;%0A
     priv
@@ -336,24 +336,24 @@
 ring field;%0A
-
     private 
@@ -536,32 +536,67 @@
 lauseInTrigger(%0A
+            @NonNull String alias,%0A
             @Non
@@ -776,32 +776,60 @@
 owerIncluded) %7B%0A
+        this.alias = alias;%0A
         this.fie
@@ -1056,16 +1056,51 @@
  range(%0A
+            @NonNull String alias,%0A
         
@@ -1329,32 +1329,55 @@
 lauseInTrigger(%0A
+                alias,%0A
                 
@@ -1580,24 +1580,59 @@
 reaterThan(%0A
+            @NonNull String alias,%0A
             
@@ -1729,32 +1729,55 @@
 lauseInTrigger(%0A
+                alias,%0A
                 
@@ -1955,32 +1955,67 @@
 aterThanEquals(%0A
+            @NonNull String alias,%0A
             @Non
@@ -2108,32 +2108,55 @@
 lauseInTrigger(%0A
+                alias,%0A
                 
@@ -2328,24 +2328,59 @@
 r lessThan(%0A
+            @NonNull String alias,%0A
             
@@ -2477,32 +2477,55 @@
 lauseInTrigger(%0A
+                alias,%0A
                 
@@ -2700,32 +2700,67 @@
 lessThanEquals(%0A
+            @NonNull String alias,%0A
             @Non
@@ -2853,32 +2853,55 @@
 lauseInTrigger(%0A
+                alias,%0A
                 
@@ -2991,32 +2991,32 @@
           null,%0A
-
                 
@@ -3021,32 +3021,110 @@
   null);%0A    %7D%0A%0A
+    @NonNull%0A    public String getAlias() %7B%0A        return this.alias;%0A    %7D%0A%0A
     @Override%0A  

Add alias to RangeClauseInTrigger