|
| 1 | +package org.kohsuke.github; |
| 2 | + |
| 3 | +/** |
| 4 | + * Lists up milestones with filtering and sorting. |
| 5 | + * |
| 6 | + * @see GHRepository#queryMilestones() GHRepository#queryMilestones() |
| 7 | + */ |
| 8 | +public class GHMilestoneQueryBuilder extends GHQueryBuilder<GHMilestone> { |
| 9 | + /** |
| 10 | + * The enum Sort. |
| 11 | + */ |
| 12 | + public enum Sort { |
| 13 | + |
| 14 | + /** Sort by completeness (percentage of issues closed). */ |
| 15 | + COMPLETENESS, |
| 16 | + /** Sort by due date. */ |
| 17 | + DUE_ON |
| 18 | + } |
| 19 | + |
| 20 | + private final GHRepository repo; |
| 21 | + |
| 22 | + /** |
| 23 | + * Instantiates a new GH milestone query builder. |
| 24 | + * |
| 25 | + * @param repo |
| 26 | + * the repo |
| 27 | + */ |
| 28 | + GHMilestoneQueryBuilder(GHRepository repo) { |
| 29 | + super(repo.root()); |
| 30 | + this.repo = repo; |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * Direction gh milestone query builder. |
| 35 | + * |
| 36 | + * @param d |
| 37 | + * the d |
| 38 | + * @return the gh milestone query builder |
| 39 | + */ |
| 40 | + public GHMilestoneQueryBuilder direction(GHDirection d) { |
| 41 | + req.with("direction", d); |
| 42 | + return this; |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * List. |
| 47 | + * |
| 48 | + * @return the paged iterable |
| 49 | + */ |
| 50 | + @Override |
| 51 | + public PagedIterable<GHMilestone> list() { |
| 52 | + return req.withUrlPath(repo.getApiTailUrl("milestones")) |
| 53 | + .toIterable(GHMilestone[].class, item -> item.lateBind(repo)); |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * Sort gh milestone query builder. |
| 58 | + * |
| 59 | + * @param sort |
| 60 | + * the sort |
| 61 | + * @return the gh milestone query builder |
| 62 | + */ |
| 63 | + public GHMilestoneQueryBuilder sort(Sort sort) { |
| 64 | + req.with("sort", sort); |
| 65 | + return this; |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * State gh milestone query builder. |
| 70 | + * |
| 71 | + * @param state |
| 72 | + * the state |
| 73 | + * @return the gh milestone query builder |
| 74 | + */ |
| 75 | + public GHMilestoneQueryBuilder state(GHIssueState state) { |
| 76 | + req.with("state", state); |
| 77 | + return this; |
| 78 | + } |
| 79 | +} |
0 commit comments