Example #1
1
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((cachedQuery == null) ? 0 : cachedQuery.hashCode());
   result = prime * result + ((dbPath == null) ? 0 : dbPath.hashCode());
   result = prime * result + (descending ? 1231 : 1237);
   result = prime * result + ((designDocId == null) ? 0 : designDocId.hashCode());
   result = prime * result + ((endDocId == null) ? 0 : endDocId.hashCode());
   result = prime * result + ((endKey == null) ? 0 : endKey.hashCode());
   result = prime * result + (group ? 1231 : 1237);
   result = prime * result + groupLevel;
   result = prime * result + (ignoreNotFound ? 1231 : 1237);
   result = prime * result + (includeDocs ? 1231 : 1237);
   result = prime * result + (inclusiveEnd ? 1231 : 1237);
   result = prime * result + ((key == null) ? 0 : key.hashCode());
   result = prime * result + limit;
   result = prime * result + ((listName == null) ? 0 : listName.hashCode());
   result = prime * result + ((queryParams == null) ? 0 : queryParams.hashCode());
   result = prime * result + (reduce ? 1231 : 1237);
   result = prime * result + skip;
   result = prime * result + ((staleOk == null) ? 0 : staleOk.hashCode());
   result = prime * result + ((startDocId == null) ? 0 : startDocId.hashCode());
   result = prime * result + ((startKey == null) ? 0 : startKey.hashCode());
   result = prime * result + ((viewName == null) ? 0 : viewName.hashCode());
   return result;
 }
Example #2
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   ViewQuery other = (ViewQuery) obj;
   if (cachedQuery == null) {
     if (other.cachedQuery != null) return false;
   } else if (!cachedQuery.equals(other.cachedQuery)) return false;
   if (dbPath == null) {
     if (other.dbPath != null) return false;
   } else if (!dbPath.equals(other.dbPath)) return false;
   if (descending != other.descending) return false;
   if (designDocId == null) {
     if (other.designDocId != null) return false;
   } else if (!designDocId.equals(other.designDocId)) return false;
   if (endDocId == null) {
     if (other.endDocId != null) return false;
   } else if (!endDocId.equals(other.endDocId)) return false;
   if (endKey == null) {
     if (other.endKey != null) return false;
   } else if (!endKey.equals(other.endKey)) return false;
   if (group != other.group) return false;
   if (groupLevel != other.groupLevel) return false;
   if (ignoreNotFound != other.ignoreNotFound) return false;
   if (includeDocs != other.includeDocs) return false;
   if (inclusiveEnd != other.inclusiveEnd) return false;
   if (key == null) {
     if (other.key != null) return false;
   } else if (!key.equals(other.key)) return false;
   if (limit != other.limit) return false;
   if (listName == null) {
     if (other.listName != null) return false;
   } else if (!listName.equals(other.listName)) return false;
   if (queryParams == null) {
     if (other.queryParams != null) return false;
   } else if (!queryParams.equals(other.queryParams)) return false;
   if (reduce != other.reduce) return false;
   if (skip != other.skip) return false;
   if (staleOk == null) {
     if (other.staleOk != null) return false;
   } else if (!staleOk.equals(other.staleOk)) return false;
   if (startDocId == null) {
     if (other.startDocId != null) return false;
   } else if (!startDocId.equals(other.startDocId)) return false;
   if (startKey == null) {
     if (other.startKey != null) return false;
   } else if (!startKey.equals(other.startKey)) return false;
   if (viewName == null) {
     if (other.viewName != null) return false;
   } else if (!viewName.equals(other.viewName)) return false;
   return true;
 }
 @SuppressWarnings("unchecked")
 @Override
 public String success(HttpResponse hr) throws Exception {
   Map<String, ?> rsp = objectMapper.readValue(hr.getContent(), Map.class);
   return (String) rsp.get(REVISION_FIELD_NAME);
 }
Example #4
0
 private void appendQueryParams(URI query) {
   for (Map.Entry<String, String> param : queryParams.entrySet()) {
     query.param(param.getKey(), param.getValue());
   }
 }
Example #5
0
  public String buildQuery() {
    if (cachedQuery != null) {
      return cachedQuery;
    }

    URI query = buildViewPath();

    if (isNotEmpty(key)) {
      query.param("key", key);
    }

    if (isNotEmpty(startKey)) {
      query.param("startkey", startKey);
    }

    if (isNotEmpty(endKey)) {
      query.param("endkey", endKey);
    }

    if (isNotEmpty(startDocId)) {
      query.param("startkey_docid", startDocId);
    }

    if (isNotEmpty(endDocId)) {
      query.param("endkey_docid", endDocId);
    }

    if (hasValue(limit)) {
      query.param("limit", limit);
    }

    if (staleOk != null) {
      query.param("stale", staleOk);
    }

    if (descending) {
      query.param("descending", "true");
    }

    if (!inclusiveEnd) {
      query.param("inclusive_end", "false");
    }

    if (!reduce) {
      query.param("reduce", "false");
    }

    if (hasValue(skip)) {
      query.param("skip", skip);
    }

    if (includeDocs) {
      query.param("include_docs", "true");
    }

    if (group) {
      query.param("group", "true");
    }

    if (hasValue(groupLevel)) {
      query.param("group_level", groupLevel);
    }

    if (queryParams != null && !queryParams.isEmpty()) {
      appendQueryParams(query);
    }

    cachedQuery = query.toString();
    return cachedQuery;
  }
Example #6
0
 public ViewQuery queryParam(String name, String value) {
   queryParams.put(name, value);
   return this;
 }