package uk.ac.ebi.quickgo.rest.search.query;

/**
 * Created 13/01/17
 * @author Edd
 */
public class RegularPage extends Page {
    private final int pageNum;

    private RegularPage(int pageSize) {
        this(1, pageSize);
    }

    public RegularPage(int pageNum, int pageSize) {
        super(pageSize);
        this.pageNum = pageNum;
    }

    public int getPageNumber() {
        return pageNum;
    }

    @Override public <V> void accept(PageVisitor<V> visitor, V subject) {
        visitor.visit(this, subject);
    }

    @Override public int hashCode() {
        return pageNum;
    }

    @Override public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        RegularPage that = (RegularPage) o;

        return pageNum == that.pageNum;
    }

    @Override public String toString() {
        return "RegularPage{" +
                "pageNum=" + pageNum +
                '}';
    }
}

@@ -39,16 +39,62 @@
 query;%0A%0A
+import com.google.common.base.Preconditions;%0A%0A
 /**%0A * C
@@ -168,16 +168,47 @@
  Page %7B%0A
+    // todo add creation tests%0A
     priv
@@ -232,16 +232,19 @@
 eNum
+ber
 ;%0A%0A    p
 riva
@@ -239,22 +239,21 @@
 ;%0A%0A    p
-rivate
+ublic
  Regular
@@ -257,24 +257,40 @@
 larPage(int 
+pageNumber, int 
 pageSize) %7B%0A
@@ -301,16 +301,14 @@
     
-this(1, 
+super(
 page
@@ -322,85 +322,92 @@
     
-%7D%0A%0A
     
-public RegularPage(int 
+Preconditions.checkArgument(
 pageNum
-, int pageSize) %7B%0A        super(pageSize
+ber %3E= 0, %22Page number cannot be less than 0%22
 );%0A 
@@ -425,16 +425,19 @@
 .pageNum
+ber
  = pageN
@@ -430,32 +430,35 @@
 Number = pageNum
+ber
 ;%0A    %7D%0A%0A    pub
@@ -497,32 +497,35 @@
   return pageNum
+ber
 ;%0A    %7D%0A%0A    @Ov
@@ -692,24 +692,27 @@
 turn pageNum
+ber
 ;%0A    %7D%0A%0A   
@@ -975,16 +975,19 @@
  pageNum
+ber
  == that
@@ -994,16 +994,19 @@
 .pageNum
+ber
 ;%0A    %7D%0A
@@ -1103,16 +1103,19 @@
 %22pageNum
+ber
 =%22 + pag
@@ -1118,16 +1118,19 @@
  pageNum
+ber
  +%0A     

add precondition on new instance argument