Skip to content

Commit b1460df

Browse files
Ruben Vittgmessner
authored andcommitted
Some fluent-API implementations (#237)
* add fluent api to event-model * add fluent api to commit-model * add fluent api to branch-model * add fluent api to eventData-model * add fluent api to protectedBranch-model * add fluent api to runner-model * add fluent api to job-model
1 parent 6893a21 commit b1460df

File tree

8 files changed

+396
-0
lines changed

8 files changed

+396
-0
lines changed

src/main/java/org/gitlab4j/api/models/Branch.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,35 @@ public void setProtected(Boolean isProtected) {
6767
public static final boolean isValid(Branch branch) {
6868
return (branch != null && branch.getName() != null);
6969
}
70+
71+
72+
public Branch withCommit(Commit commit) {
73+
this.commit = commit;
74+
return this;
75+
}
76+
77+
public Branch withDevelopersCanMerge(Boolean developersCanMerge) {
78+
this.developersCanMerge = developersCanMerge;
79+
return this;
80+
}
81+
82+
public Branch withDevelopersCanPush(Boolean developersCanPush) {
83+
this.developersCanPush = developersCanPush;
84+
return this;
85+
}
86+
87+
public Branch withDerged(Boolean merged) {
88+
this.merged = merged;
89+
return this;
90+
}
91+
92+
public Branch withName(String name) {
93+
this.name = name;
94+
return this;
95+
}
96+
97+
public Branch withIsProtected(Boolean isProtected) {
98+
this.isProtected = isProtected;
99+
return this;
100+
}
70101
}

src/main/java/org/gitlab4j/api/models/Commit.java

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,90 @@ public String getUrl() {
165165
public void setUrl(String url) {
166166
this.url = url;
167167
}
168+
169+
170+
public Commit withAuthor(Author author) {
171+
this.author = author;
172+
return this;
173+
}
174+
175+
public Commit withAuthoredDate(Date authoredDate) {
176+
this.authoredDate = authoredDate;
177+
return this;
178+
}
179+
180+
public Commit withAuthorEmail(String authorEmail) {
181+
this.authorEmail = authorEmail;
182+
return this;
183+
}
184+
185+
public Commit withAuthorName(String authorName) {
186+
this.authorName = authorName;
187+
return this;
188+
}
189+
190+
public Commit withCommittedDate(Date committedDate) {
191+
this.committedDate = committedDate;
192+
return this;
193+
}
194+
195+
public Commit withCommitterEmail(String committerEmail) {
196+
this.committerEmail = committerEmail;
197+
return this;
198+
}
199+
200+
public Commit withCommitterName(String committerName) {
201+
this.committerName = committerName;
202+
return this;
203+
}
204+
205+
public Commit withCreatedAt(Date createdAt) {
206+
this.createdAt = createdAt;
207+
return this;
208+
}
209+
210+
public Commit withId(String id) {
211+
this.id = id;
212+
return this;
213+
}
214+
215+
public Commit withMessage(String message) {
216+
this.message = message;
217+
return this;
218+
}
219+
220+
public Commit withParentIds(List<String> parentIds) {
221+
this.parentIds = parentIds;
222+
return this;
223+
}
224+
225+
public Commit withShorwId(String shortId) {
226+
this.shortId = shortId;
227+
return this;
228+
}
229+
230+
public Commit withStats(CommitStats stats) {
231+
this.stats = stats;
232+
return this;
233+
}
234+
235+
public Commit withStatus(String status) {
236+
this.status = status;
237+
return this;
238+
}
239+
240+
public Commit withTimestamp(Date timestamp) {
241+
this.timestamp = timestamp;
242+
return this;
243+
}
244+
245+
public Commit withTitle(String title) {
246+
this.title = title;
247+
return this;
248+
}
249+
250+
public Commit withUrl(String url) {
251+
this.url = url;
252+
return this;
253+
}
168254
}

src/main/java/org/gitlab4j/api/models/Event.java

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,64 @@ public PushData getPushData() {
140140
public void setPushData(PushData pushData) {
141141
this.pushData = pushData;
142142
}
143+
144+
public Event withActionName(String actionName) {
145+
this.actionName = actionName;
146+
return this;
147+
}
148+
149+
public Event withAuthor(Author author) {
150+
this.author = author;
151+
return this;
152+
}
153+
154+
public Event withAuthorId(Integer authorId) {
155+
this.authorId = authorId;
156+
return this;
157+
}
158+
159+
public Event withAuthorUsername(String authorUsername) {
160+
this.authorUsername = authorUsername;
161+
return this;
162+
}
163+
164+
public Event withData(EventData data) {
165+
this.data = data;
166+
return this;
167+
}
168+
169+
public Event withProjectId(Integer projectId) {
170+
this.projectId = projectId;
171+
return this;
172+
}
173+
174+
public Event withTargetId(Integer targetId) {
175+
this.targetId = targetId;
176+
return this;
177+
}
178+
179+
public Event withTargetIid(Integer targetIid) {
180+
this.targetIid = targetIid;
181+
return this;
182+
}
183+
184+
public Event withTargetTitle(String targetTitle) {
185+
this.targetTitle = targetTitle;
186+
return this;
187+
}
188+
189+
public Event withTargetType(TargetType targetType) {
190+
this.targetType = targetType;
191+
return this;
192+
}
193+
194+
public Event withTitle(String title) {
195+
this.title = title;
196+
return this;
197+
}
198+
199+
public Event withCreatedAt(Date createdAt) {
200+
this.createdAt = createdAt;
201+
return this;
202+
}
143203
}

src/main/java/org/gitlab4j/api/models/EventData.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,45 @@ public String getUserName() {
8383
public void setUserName(String userName) {
8484
this.userName = userName;
8585
}
86+
87+
88+
public EventData withAfter(String after) {
89+
this.after = after;
90+
return this;
91+
}
92+
93+
public EventData withBefore(String before) {
94+
this.before = before;
95+
return this;
96+
}
97+
98+
public EventData withCommits(List<Commit> commits) {
99+
this.commits = commits;
100+
return this;
101+
}
102+
103+
public EventData withRef(String ref) {
104+
this.ref = ref;
105+
return this;
106+
}
107+
108+
public EventData withRepository(Repository repository) {
109+
this.repository = repository;
110+
return this;
111+
}
112+
113+
public EventData withTotalCommitsCount(Integer totalCommitsCount) {
114+
this.totalCommitsCount = totalCommitsCount;
115+
return this;
116+
}
117+
118+
public EventData withUserId(Integer userId) {
119+
this.userId = userId;
120+
return this;
121+
}
122+
123+
public EventData withUserName(String userName) {
124+
this.userName = userName;
125+
return this;
126+
}
86127
}

src/main/java/org/gitlab4j/api/models/Job.java

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,80 @@ public Runner getRunner() {
144144
public void setRunner(Runner runner) {
145145
this.runner = runner;
146146
}
147+
148+
149+
public Job withId(Integer id) {
150+
this.id = id;
151+
return this;
152+
}
153+
154+
public Job withCommit(Commit commit) {
155+
this.commit = commit;
156+
return this;
157+
}
158+
159+
public Job withCoverage(String coverage) {
160+
this.coverage = coverage;
161+
return this;
162+
}
163+
164+
public Job withCreatedAt(Date createdAt) {
165+
this.createdAt = createdAt;
166+
return this;
167+
}
168+
169+
public Job withFinishedAt(Date finishedAt) {
170+
this.finishedAt = finishedAt;
171+
return this;
172+
}
173+
174+
public Job withName(String name) {
175+
this.name = name;
176+
return this;
177+
}
178+
179+
public Job withPipeline(Pipeline pipeline) {
180+
this.pipeline = pipeline;
181+
return this;
182+
}
183+
184+
public Job withRef(String ref) {
185+
this.ref = ref;
186+
return this;
187+
}
188+
189+
public Job withRunner(Runner runner) {
190+
this.runner = runner;
191+
return this;
192+
}
193+
194+
public Job withUser(User user) {
195+
this.user = user;
196+
return this;
197+
}
198+
199+
public Job withStartedAt(Date startedAt) {
200+
this.startedAt = startedAt;
201+
return this;
202+
}
203+
204+
public Job withArtifactsFile(ArtifactsFile artifactsFile) {
205+
this.artifactsFile = artifactsFile;
206+
return this;
207+
}
208+
209+
public Job withTag(Boolean tag) {
210+
this.tag = tag;
211+
return this;
212+
}
213+
214+
public Job withStage(String stage) {
215+
this.stage = stage;
216+
return this;
217+
}
218+
219+
public Job withStatus(JobStatus status) {
220+
this.status = status;
221+
return this;
222+
}
147223
}

src/main/java/org/gitlab4j/api/models/ProtectedBranch.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,20 @@ public void setMergeAccessLevels(List<BranchAccessLevel> mergeAccessLevels) {
4141
public static final boolean isValid(ProtectedBranch branch) {
4242
return (branch != null && branch.getName() != null);
4343
}
44+
45+
46+
public ProtectedBranch withName(String name) {
47+
this.name = name;
48+
return this;
49+
}
50+
51+
public ProtectedBranch withPushAccessLevels(List<BranchAccessLevel> pushAccessLevels) {
52+
this.pushAccessLevels = pushAccessLevels;
53+
return this;
54+
}
55+
56+
public ProtectedBranch withMergeAccessLevels(List<BranchAccessLevel> mergeAccessLevels) {
57+
this.mergeAccessLevels = mergeAccessLevels;
58+
return this;
59+
}
4460
}

src/main/java/org/gitlab4j/api/models/Runner.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,45 @@ public String getIpAddress() {
109109
public void setIpAddress(String ipAddress) {
110110
this.ipAddress = ipAddress;
111111
}
112+
113+
114+
public Runner withId(Integer id) {
115+
this.id = id;
116+
return this;
117+
}
118+
119+
public Runner withDescription(String description) {
120+
this.description = description;
121+
return this;
122+
}
123+
124+
public Runner withActive(Boolean active) {
125+
this.active = active;
126+
return this;
127+
}
128+
129+
public Runner withIsShared(Boolean isShared) {
130+
this.isShared = isShared;
131+
return this;
132+
}
133+
134+
public Runner withName(String name) {
135+
this.name = name;
136+
return this;
137+
}
138+
139+
public Runner withOnline(Boolean online) {
140+
this.online = online;
141+
return this;
142+
}
143+
144+
public Runner withStatus(RunnerStatus status) {
145+
this.status = status;
146+
return this;
147+
}
148+
149+
public Runner withIpAddress(String ipAddress) {
150+
this.ipAddress = ipAddress;
151+
return this;
152+
}
112153
}

0 commit comments

Comments
 (0)