[Lada-commits] [PATCH 1 of 5] Added attribute 'totalcount' to response

Wald Commits scm-commit at wald.intevation.org
Wed Oct 9 14:54:06 CEST 2013


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1381322981 -7200
# Node ID a1cef118c32ab5bbe986ccb5d0b8f7906e4d3a72
# Parent  6f4afcd28ff33c67b65645f5b3fe1db02955a163
Added attribute 'totalcount' to response.

diff -r 6f4afcd28ff3 -r a1cef118c32a src/main/java/de/intevation/lada/rest/Response.java
--- a/src/main/java/de/intevation/lada/rest/Response.java	Fri Sep 27 10:20:19 2013 +0200
+++ b/src/main/java/de/intevation/lada/rest/Response.java	Wed Oct 09 14:49:41 2013 +0200
@@ -28,6 +28,7 @@
     private Map<String, String> errors;
     private Map<String, String> warnings;
     private Boolean readonly;
+    private int totalCount;
 
     /**
      * Constructor to create a basic Response object.
@@ -43,6 +44,24 @@
         this.errors = new HashMap<String, String>();
         this.warnings = new HashMap<String, String>();
         this.readonly = Boolean.FALSE;
+        this.totalCount = 0;
+    }
+
+    /**
+     * Constructor to create a basic Response object.
+     *
+     * @param success   Information if the operation was successful.
+     * @param code      The return code.
+     * @param data      The data object wrapped by the response.
+     */
+    public Response(boolean success, int code, Object data, int totalCount) {
+        this.success = success;
+        this.message = Integer.toString(code);
+        this.data = data;
+        this.errors = new HashMap<String, String>();
+        this.warnings = new HashMap<String, String>();
+        this.readonly = Boolean.FALSE;
+        this.totalCount = totalCount;
     }
 
     public Boolean getSuccess() {
@@ -93,6 +112,20 @@
         this.readonly = readonly;
     }
 
+    /**
+     * @return the totalCount
+     */
+    public int getTotalCount() {
+        return totalCount;
+    }
+
+    /**
+     * @param totalCount the totalCount to set
+     */
+    public void setTotalCount(int totalCount) {
+        this.totalCount = totalCount;
+    }
+
     private HashMap<String, String> convertCodes(Map<String, Integer> codes) {
         HashMap<String, String> converted = new HashMap<String, String>();
         if (codes == null || codes.isEmpty()) {


More information about the Lada-commits mailing list