package com.google.job.data;

import javax.annotation.Nullable;

/** Class for the job listings query. */
public static final class JobQuery {
    // Optional parameters - initialized to default values
    private int minLimit = 0;
    private int maxLimit = Integer.MAX_VALUE;
    private SingaporeRegion region = SingaporeRegion.ENTIRE;
    private Filter sortBy = Filter.SALARY;
    private Order order = Order.DESCENDING;
    private int pageSize = 100;
    private int pageIndex = 0;

    private JobQuery() {}	

    public JobQuery setMinLimit(int minLimit) {
        assert minLimit >= 0;
        this.minLimit = minLimit;
        return this;
    }

    public JobQuery setMaxLimit(int maxLimit) {
        assert val > 0 && val >= this.minLimit;
        this.maxLimit = maxLimit;
        return this;
    }

    public JobQuery setRegion(SingaporeRegion region) {
        this.region = region;
        return this;
    }

    public JobQuery setSortBy(Filter sortBy) {
        this.sortBy = sortBy;
        return this;
    }

    public JobQuery setOrder(Order order) {
        this.order = order;
        return this;
    }

    public JobQuery setPageSize(int pageSize) {
        assert pageSize >= 1;
        this.pageSize = pageSize;
        return this;
    }

    public JobQuery setPageIndex(int pageIndex) {
        assert pageIndex >= 0;
        this.pageIndex = pageIndex;
        return this;
    }

    public JobQuery build() {     
        return new JobQuery(this);
    }

    /** Returns the lower limit for the filter. */
    public int getMinLimit() {
        return minLimit;
    }

    /** Returns the upper limit for the filter. */
    public int getMaxLimit() {
        return maxLimit;
    }

    /** Returns the region in Singapore. */
    public SingaporeRegion getRegion() {
        return region;
    }

    /** Returns the sorting. */
    public Filter getSortBy() {
        return sortBy;
    }

    /** Returns the ordering of the sorting. */
    public Order getOrder() {
        return order;
    }

    /** Returns the page size. */
    public int getPageSize() {
        return pageSize;
    }

    /** Returns a page number (or index). */
    public int getPageIndex() {
        return pageIndex;
    }
}

@@ -94,16 +94,38 @@
 gs query
+ using builder pattern
 . */%0Apub
@@ -132,15 +132,8 @@
 lic 
-static 
 fina
@@ -155,67 +155,8 @@
 y %7B%0A
-    // Optional parameters - initialized to default values%0A
     
@@ -444,22 +444,21 @@
 ;%0A%0A    p
-rivate
+ublic
  JobQuer
@@ -673,22 +673,32 @@
 ert 
-val %3E 0 && val
+maxLimit %3E 0 && maxLimit
  %3E= 
@@ -1346,24 +1346,24 @@
  pageIndex;%0A
+
         retu
@@ -1382,85 +1382,8 @@
  %7D%0A%0A
-    public JobQuery build() %7B     %0A        return new JobQuery(this);%0A    %7D%0A%0A
     

remove builder method