Back to project page dashclock-gerrit.
The source code is released under:
Apache License
If you think the Android project dashclock-gerrit listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.plusonelabs.dashclock.gerrit; /*from w ww . j a v a 2 s.c om*/ import static com.plusonelabs.dashclock.gerrit.util.ParamCheck.*; import static com.plusonelabs.dashclock.gerrit.util.StringUtil.*; import com.plusonelabs.dashclock.gerrit.util.UrlUtil; public class QueryBuilder { private final String baseUrl; private final boolean anonymous; private String branch; private String project; private String reviewer; public QueryBuilder(String baseUrl, boolean anonymous) { paramNotNull(baseUrl, "baseUrl"); this.baseUrl = baseUrl; this.anonymous = anonymous; } public void setProject(String project) { this.project = project; } public void setBranch(String branch) { this.branch = branch; } public void setReviewer(String reviewer) { this.reviewer = reviewer; } public String createQueryUrl() { String queryUrl = UrlUtil.appendPath(baseUrl, "changes/?"); queryUrl += createQueryChanges(); if (!anonymous) { queryUrl += "&"; queryUrl += createQueryChanges(); queryUrl += "+reviewer:self"; } else if (hasContent(reviewer)) { queryUrl += "&"; queryUrl += createQueryChanges(); queryUrl += "+reviewer:" + reviewer; } return queryUrl; } private String createQueryChanges() { String query = "q=is:open"; query += createParamProject(); query += createParamBranch(); return query; } private String createParamProject() { if (hasContent(project)) { return "+project:" + project; } return EMPTY_STRING; } private String createParamBranch() { if (hasContent(branch)) { return "+branch:" + branch; } return EMPTY_STRING; } }