|
| 1 | +package org.gitlab4j.api.models; |
| 2 | + |
| 3 | +import java.util.Date; |
| 4 | +import java.util.List; |
| 5 | + |
| 6 | +import org.gitlab4j.api.Constants; |
| 7 | +import org.gitlab4j.api.Constants.MergeRequestOrderBy; |
| 8 | +import org.gitlab4j.api.Constants.MergeRequestScope; |
| 9 | +import org.gitlab4j.api.Constants.MergeRequestState; |
| 10 | +import org.gitlab4j.api.Constants.SortOrder; |
| 11 | +import org.gitlab4j.api.GitLabApiForm; |
| 12 | + |
| 13 | +import com.fasterxml.jackson.annotation.JsonIgnore; |
| 14 | + |
| 15 | +/** |
| 16 | + * This class is used to filter merge requests when getting lists of them. |
| 17 | + */ |
| 18 | +public class MergeRequestFilter { |
| 19 | + |
| 20 | + private MergeRequestState state; |
| 21 | + private MergeRequestOrderBy orderBy; |
| 22 | + private SortOrder sort; |
| 23 | + private String milestone; |
| 24 | + private Boolean simpleView; |
| 25 | + private List<String> labels; |
| 26 | + private Date createdAfter; |
| 27 | + private Date createdBefore; |
| 28 | + private Date updatedAfter; |
| 29 | + private Date updatedBefore; |
| 30 | + private MergeRequestScope scope; |
| 31 | + private Integer authorId; |
| 32 | + private Integer assigneeId; |
| 33 | + private String myReactionEmoji; |
| 34 | + private String sourceBranch; |
| 35 | + private String targetBranch; |
| 36 | + private String search; |
| 37 | + |
| 38 | + public MergeRequestState getState() { |
| 39 | + return state; |
| 40 | + } |
| 41 | + |
| 42 | + public void setState(MergeRequestState state) { |
| 43 | + this.state = state; |
| 44 | + } |
| 45 | + |
| 46 | + public MergeRequestFilter withState(MergeRequestState state) { |
| 47 | + this.state = state; |
| 48 | + return (this); |
| 49 | + } |
| 50 | + |
| 51 | + public MergeRequestOrderBy getOrderBy() { |
| 52 | + return orderBy; |
| 53 | + } |
| 54 | + |
| 55 | + public void setOrderBy(MergeRequestOrderBy orderBy) { |
| 56 | + this.orderBy = orderBy; |
| 57 | + } |
| 58 | + |
| 59 | + public MergeRequestFilter withOrderBy(MergeRequestOrderBy orderBy) { |
| 60 | + this.orderBy = orderBy; |
| 61 | + return (this); |
| 62 | + } |
| 63 | + |
| 64 | + public SortOrder getSort() { |
| 65 | + return sort; |
| 66 | + } |
| 67 | + |
| 68 | + public void setSort(SortOrder sort) { |
| 69 | + this.sort = sort; |
| 70 | + } |
| 71 | + |
| 72 | + public MergeRequestFilter withSort(SortOrder sort) { |
| 73 | + this.sort = sort; |
| 74 | + return (this); |
| 75 | + } |
| 76 | + |
| 77 | + public String getMilestone() { |
| 78 | + return milestone; |
| 79 | + } |
| 80 | + |
| 81 | + public void setMilestone(String milestone) { |
| 82 | + this.milestone = milestone; |
| 83 | + } |
| 84 | + |
| 85 | + public MergeRequestFilter withMilestone(String milestone) { |
| 86 | + this.milestone = milestone; |
| 87 | + return (this); |
| 88 | + } |
| 89 | + |
| 90 | + public Boolean getSimpleView() { |
| 91 | + return simpleView; |
| 92 | + } |
| 93 | + |
| 94 | + public void setSimpleView(Boolean simpleView) { |
| 95 | + this.simpleView = simpleView; |
| 96 | + } |
| 97 | + |
| 98 | + public MergeRequestFilter withSimpleView(Boolean simpleView) { |
| 99 | + this.simpleView = simpleView; |
| 100 | + return (this); |
| 101 | + } |
| 102 | + |
| 103 | + public List<String> getLabels() { |
| 104 | + return labels; |
| 105 | + } |
| 106 | + |
| 107 | + public void setLabels(List<String> labels) { |
| 108 | + this.labels = labels; |
| 109 | + } |
| 110 | + |
| 111 | + public MergeRequestFilter withLabels(List<String> labels) { |
| 112 | + this.labels = labels; |
| 113 | + return (this); |
| 114 | + } |
| 115 | + |
| 116 | + public Date getCreatedAfter() { |
| 117 | + return createdAfter; |
| 118 | + } |
| 119 | + |
| 120 | + public void setCreatedAfter(Date createdAfter) { |
| 121 | + this.createdAfter = createdAfter; |
| 122 | + } |
| 123 | + |
| 124 | + public MergeRequestFilter withCreatedAfter(Date createdAfter) { |
| 125 | + this.createdAfter = createdAfter; |
| 126 | + return (this); |
| 127 | + } |
| 128 | + |
| 129 | + public Date getCreatedBefore() { |
| 130 | + return createdBefore; |
| 131 | + } |
| 132 | + |
| 133 | + public void setCreatedBefore(Date createdBefore) { |
| 134 | + this.createdBefore = createdBefore; |
| 135 | + } |
| 136 | + |
| 137 | + public MergeRequestFilter withCreatedBefore(Date createdBefore) { |
| 138 | + this.createdBefore = createdBefore; |
| 139 | + return (this); |
| 140 | + } |
| 141 | + |
| 142 | + public Date getUpdatedAfter() { |
| 143 | + return updatedAfter; |
| 144 | + } |
| 145 | + |
| 146 | + public void setUpdatedAfter(Date updatedAfter) { |
| 147 | + this.updatedAfter = updatedAfter; |
| 148 | + } |
| 149 | + |
| 150 | + public MergeRequestFilter withUpdatedAfter(Date updatedAfter) { |
| 151 | + this.updatedAfter = updatedAfter; |
| 152 | + return (this); |
| 153 | + } |
| 154 | + |
| 155 | + public Date getUpdatedBefore() { |
| 156 | + return updatedBefore; |
| 157 | + } |
| 158 | + |
| 159 | + public void setUpdatedBefore(Date updatedBefore) { |
| 160 | + this.updatedBefore = updatedBefore; |
| 161 | + } |
| 162 | + |
| 163 | + public MergeRequestFilter withUpdatedBefore(Date updatedBefore) { |
| 164 | + this.updatedBefore = updatedBefore; |
| 165 | + return (this); |
| 166 | + } |
| 167 | + |
| 168 | + public MergeRequestScope getScope() { |
| 169 | + return scope; |
| 170 | + } |
| 171 | + |
| 172 | + public void setScope(MergeRequestScope scope) { |
| 173 | + this.scope = scope; |
| 174 | + } |
| 175 | + |
| 176 | + public MergeRequestFilter withScope(MergeRequestScope scope) { |
| 177 | + this.scope = scope; |
| 178 | + return (this); |
| 179 | + } |
| 180 | + |
| 181 | + public Integer getAuthorId() { |
| 182 | + return authorId; |
| 183 | + } |
| 184 | + |
| 185 | + public void setAuthorId(Integer authorId) { |
| 186 | + this.authorId = authorId; |
| 187 | + } |
| 188 | + |
| 189 | + public MergeRequestFilter withAuthorId(Integer authorId) { |
| 190 | + this.authorId = authorId; |
| 191 | + return (this); |
| 192 | + } |
| 193 | + |
| 194 | + public Integer getAssigneeId() { |
| 195 | + return assigneeId; |
| 196 | + } |
| 197 | + |
| 198 | + public void setAssigneeId(Integer assigneeId) { |
| 199 | + this.assigneeId = assigneeId; |
| 200 | + } |
| 201 | + |
| 202 | + public MergeRequestFilter withAssigneeId(Integer assigneeId) { |
| 203 | + this.assigneeId = assigneeId; |
| 204 | + return (this); |
| 205 | + } |
| 206 | + |
| 207 | + public String getMyReactionEmoji() { |
| 208 | + return myReactionEmoji; |
| 209 | + } |
| 210 | + |
| 211 | + public void setMyReactionEmoji(String myReactionEmoji) { |
| 212 | + this.myReactionEmoji = myReactionEmoji; |
| 213 | + } |
| 214 | + |
| 215 | + public MergeRequestFilter withMyReactionEmoji(String myReactionEmoji) { |
| 216 | + this.myReactionEmoji = myReactionEmoji; |
| 217 | + return (this); |
| 218 | + } |
| 219 | + |
| 220 | + public String getSourceBranch() { |
| 221 | + return sourceBranch; |
| 222 | + } |
| 223 | + |
| 224 | + public void setSourceBranch(String sourceBranch) { |
| 225 | + this.sourceBranch = sourceBranch; |
| 226 | + } |
| 227 | + |
| 228 | + public MergeRequestFilter withSourceBranch(String sourceBranch) { |
| 229 | + this.sourceBranch = sourceBranch; |
| 230 | + return (this); |
| 231 | + } |
| 232 | + |
| 233 | + public String getTargetBranch() { |
| 234 | + return targetBranch; |
| 235 | + } |
| 236 | + |
| 237 | + public void setTargetBranch(String targetBranch) { |
| 238 | + this.targetBranch = targetBranch; |
| 239 | + } |
| 240 | + |
| 241 | + public MergeRequestFilter withTargetBranch(String targetBranch) { |
| 242 | + this.targetBranch = targetBranch; |
| 243 | + return (this); |
| 244 | + } |
| 245 | + |
| 246 | + public String getSearch() { |
| 247 | + return search; |
| 248 | + } |
| 249 | + |
| 250 | + public void setSearch(String search) { |
| 251 | + this.search = search; |
| 252 | + } |
| 253 | + |
| 254 | + public MergeRequestFilter withSearch(String search) { |
| 255 | + this.search = search; |
| 256 | + return (this); |
| 257 | + } |
| 258 | + |
| 259 | + @JsonIgnore |
| 260 | + public GitLabApiForm getQueryParams(int page, int perPage) { |
| 261 | + return (getQueryParams() |
| 262 | + .withParam(Constants.PAGE_PARAM, page) |
| 263 | + .withParam(Constants.PER_PAGE_PARAM, perPage)); |
| 264 | + } |
| 265 | + |
| 266 | + @JsonIgnore |
| 267 | + public GitLabApiForm getQueryParams() { |
| 268 | + return (new GitLabApiForm() |
| 269 | + .withParam("state", state) |
| 270 | + .withParam("order_by", orderBy) |
| 271 | + .withParam("sort", sort) |
| 272 | + .withParam("milestone", milestone) |
| 273 | + .withParam("view", (simpleView != null && simpleView ? "simple" : null)) |
| 274 | + .withParam("labels", labels) |
| 275 | + .withParam("created_after", createdAfter) |
| 276 | + .withParam("created_before", createdBefore) |
| 277 | + .withParam("updated_after", updatedAfter) |
| 278 | + .withParam("updated_before", updatedBefore) |
| 279 | + .withParam("scope", scope) |
| 280 | + .withParam("assignee_id", assigneeId) |
| 281 | + .withParam("my_reaction_emoji", myReactionEmoji) |
| 282 | + .withParam("source_branch", sourceBranch) |
| 283 | + .withParam("target_branch", targetBranch) |
| 284 | + .withParam("search", search)); |
| 285 | + } |
| 286 | +} |
0 commit comments