Projects: Pass more arguments from ListRequest to ListProjects

Change-Id: I2fe0954b3edff569b0d3bf0b1edc0a41f335d7f1
This commit is contained in:
Dave Borowitz
2015-03-13 10:11:19 -07:00
parent 795958cdc6
commit 2ab016bf9a
2 changed files with 83 additions and 0 deletions

View File

@@ -43,10 +43,19 @@ public interface Projects {
ListRequest list();
public abstract class ListRequest {
public static enum FilterType {
CODE, PARENT_CANDIDATES, PERMISSIONS, ALL;
}
private final List<String> branches = new ArrayList<>();
private boolean description;
private String prefix;
private String substring;
private String regex;
private int limit;
private int start;
private boolean showTree;
private FilterType type = FilterType.ALL;
public List<ProjectInfo> get() throws RestApiException {
Map<String, ProjectInfo> map = getAsMap();
@@ -72,6 +81,16 @@ public interface Projects {
return this;
}
public ListRequest withSubstring(String substring) {
this.substring = substring;
return this;
}
public ListRequest withRegex(String regex) {
this.regex = regex;
return this;
}
public ListRequest withLimit(int limit) {
this.limit = limit;
return this;
@@ -82,6 +101,21 @@ public interface Projects {
return this;
}
public ListRequest addShowBranch(String branch) {
branches.add(branch);
return this;
}
public ListRequest withTree(boolean show) {
showTree = show;
return this;
}
public ListRequest withType(FilterType type) {
this.type = type != null ? type : FilterType.ALL;
return this;
}
public boolean getDescription() {
return description;
}
@@ -90,6 +124,14 @@ public interface Projects {
return prefix;
}
public String getSubstring() {
return substring;
}
public String getRegex() {
return regex;
}
public int getLimit() {
return limit;
}
@@ -97,6 +139,18 @@ public interface Projects {
public int getStart() {
return start;
}
public List<String> getBranches() {
return Collections.unmodifiableList(branches);
}
public boolean getShowTree() {
return showTree;
}
public FilterType getFilterType() {
return type;
}
}
/**