Repository navigation
Expand file tree
/
Copy pathGHIssueBuilder.java
More file actions
124 lines (114 loc) · 2.88 KB
/
Copy pathGHIssueBuilder.java
File metadata and controls
124 lines (114 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package org.kohsuke.github;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
// TODO: Auto-generated Javadoc
/**
* The type GHIssueBuilder.
*
* @author Kohsuke Kawaguchi
*/
public class GHIssueBuilder {
private List<String> assignees = new ArrayList<String>();
private final Requester builder;
private List<String> labels = new ArrayList<String>();
private final GHRepository repo;
/**
* Instantiates a new GH issue builder.
*
* @param repo
* the repo
* @param title
* the title
*/
GHIssueBuilder(GHRepository repo, String title) {
this.repo = repo;
this.builder = repo.root().createRequest().method("POST");
builder.with("title", title);
}
/**
* Assignee gh issue builder.
*
* @param user
* the user
* @return the gh issue builder
*/
public GHIssueBuilder assignee(GHUser user) {
if (user != null)
assignees.add(user.getLogin());
return this;
}
/**
* Assignee gh issue builder.
*
* @param user
* the user
* @return the gh issue builder
*/
public GHIssueBuilder assignee(String user) {
if (user != null)
assignees.add(user);
return this;
}
/**
* Sets the main text of an issue, which is arbitrary multi-line text.
*
* @param str
* the str
* @return the gh issue builder
*/
public GHIssueBuilder body(String str) {
builder.with("body", str);
return this;
}
/**
* Creates a new issue.
*
* @return the gh issue
* @throws IOException
* the io exception
*/
public GHIssue create() throws IOException {
return builder.with("labels", labels)
.with("assignees", assignees)
.withUrlPath(repo.getApiTailUrl("issues"))
.fetch(GHIssue.class)
.wrap(repo);
}
/**
* Label gh issue builder.
*
* @param label
* the label
* @return the gh issue builder
*/
public GHIssueBuilder label(String label) {
if (label != null)
labels.add(label);
return this;
}
/**
* Milestone gh issue builder.
*
* @param milestone
* the milestone
* @return the gh issue builder
*/
public GHIssueBuilder milestone(GHMilestone milestone) {
if (milestone != null)
builder.with("milestone", milestone.getNumber());
return this;
}
/**
* Assigns an issue type by name.
*
* @param type
* the issue type name
* @return the gh issue builder
*/
public GHIssueBuilder type(String type) {
if (type != null)
builder.with("type", type);
return this;
}
}