Skip to content

Commit cab7f05

Browse files
mdeknowisgmessner
authored andcommitted
Add withXxxxx() methods to AbstractUser (#273)
1 parent c922529 commit cab7f05

File tree

6 files changed

+211
-90
lines changed

6 files changed

+211
-90
lines changed

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

Lines changed: 194 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
@XmlAccessorType(XmlAccessType.FIELD)
1212
@JsonIgnoreProperties(ignoreUnknown = true)
13-
public class AbstractUser {
13+
public abstract class AbstractUser<U extends AbstractUser<U>> {
1414

1515
private String avatarUrl;
1616
private String bio;
@@ -300,4 +300,197 @@ public List<CustomAttribute> getCustomAttributes() {
300300
public void setCustomAttributes(List<CustomAttribute> customAttributes) {
301301
this.customAttributes = customAttributes;
302302
}
303+
304+
305+
@SuppressWarnings("unchecked")
306+
public U withAvatarUrl(String avatarUrl) {
307+
this.avatarUrl = avatarUrl;
308+
return (U)this;
309+
}
310+
311+
@SuppressWarnings("unchecked")
312+
public U withBio(String bio) {
313+
this.bio = bio;
314+
return (U)this;
315+
}
316+
317+
@SuppressWarnings("unchecked")
318+
public U withCanCreateGroup(Boolean canCreateGroup) {
319+
this.canCreateGroup = canCreateGroup;
320+
return (U)this;
321+
}
322+
323+
@SuppressWarnings("unchecked")
324+
public U withCanCreateProject(Boolean canCreateProject) {
325+
this.canCreateProject = canCreateProject;
326+
return (U)this;
327+
}
328+
329+
@SuppressWarnings("unchecked")
330+
public U withColorSchemeId(Integer colorSchemeId) {
331+
this.colorSchemeId = colorSchemeId;
332+
return (U)this;
333+
}
334+
335+
@SuppressWarnings("unchecked")
336+
public U withConfirmedAt(Date confirmedAt) {
337+
this.confirmedAt = confirmedAt;
338+
return (U)this;
339+
}
340+
341+
@SuppressWarnings("unchecked")
342+
public U withCreatedAt(Date createdAt) {
343+
this.createdAt = createdAt;
344+
return (U)this;
345+
}
346+
347+
@SuppressWarnings("unchecked")
348+
public U withCurrentSignInAt(Date currentSignInAt) {
349+
this.currentSignInAt = currentSignInAt;
350+
return (U)this;
351+
}
352+
353+
@SuppressWarnings("unchecked")
354+
public U withEmail(String email) {
355+
this.email = email;
356+
return (U)this;
357+
}
358+
359+
@SuppressWarnings("unchecked")
360+
public U withExternal(Boolean external) {
361+
this.external = external;
362+
return (U)this;
363+
}
364+
365+
@SuppressWarnings("unchecked")
366+
public U withId(Integer id) {
367+
this.id = id;
368+
return (U)this;
369+
}
370+
371+
@SuppressWarnings("unchecked")
372+
public U withIdentities(List<Identity> identities) {
373+
this.identities = identities;
374+
return (U)this;
375+
}
376+
377+
@SuppressWarnings("unchecked")
378+
public U withIsAdmin(Boolean isAdmin) {
379+
this.isAdmin = isAdmin;
380+
return (U)this;
381+
}
382+
383+
@SuppressWarnings("unchecked")
384+
public U withLastActivityOn(Date lastActivityOn) {
385+
this.lastActivityOn = lastActivityOn;
386+
return (U)this;
387+
}
388+
389+
@SuppressWarnings("unchecked")
390+
public U withLastSignInAt(Date lastSignInAt) {
391+
this.lastSignInAt = lastSignInAt;
392+
return (U)this;
393+
}
394+
395+
@SuppressWarnings("unchecked")
396+
public U withLinkedin(String linkedin) {
397+
this.linkedin = linkedin;
398+
return (U)this;
399+
}
400+
401+
@SuppressWarnings("unchecked")
402+
public U withLocation(String location) {
403+
this.location = location;
404+
return (U)this;
405+
}
406+
407+
@SuppressWarnings("unchecked")
408+
public U withName(String name) {
409+
this.name = name;
410+
return (U)this;
411+
}
412+
413+
@SuppressWarnings("unchecked")
414+
public U withOrganization(String organization) {
415+
this.organization = organization;
416+
return (U)this;
417+
}
418+
419+
@SuppressWarnings("unchecked")
420+
public U withProjectsLimit(Integer projectsLimit) {
421+
this.projectsLimit = projectsLimit;
422+
return (U)this;
423+
}
424+
425+
@SuppressWarnings("unchecked")
426+
public U withProvider(String provider) {
427+
this.provider = provider;
428+
return (U)this;
429+
}
430+
431+
@SuppressWarnings("unchecked")
432+
public U withSharedRunnersMinutesLimit(Integer sharedRunnersMinutesLimit) {
433+
this.sharedRunnersMinutesLimit = sharedRunnersMinutesLimit;
434+
return (U)this;
435+
}
436+
437+
@SuppressWarnings("unchecked")
438+
public U withSkype(String skype) {
439+
this.skype = skype;
440+
return (U)this;
441+
}
442+
443+
@SuppressWarnings("unchecked")
444+
public U withState(String state) {
445+
this.state = state;
446+
return (U)this;
447+
}
448+
449+
@SuppressWarnings("unchecked")
450+
public U withThemeId(Integer themeId) {
451+
this.themeId = themeId;
452+
return (U)this;
453+
}
454+
455+
@SuppressWarnings("unchecked")
456+
public U withTwitter(String twitter) {
457+
this.twitter = twitter;
458+
return (U)this;
459+
}
460+
461+
@SuppressWarnings("unchecked")
462+
public U withTwoFactorEnabled(Boolean twoFactorEnabled) {
463+
this.twoFactorEnabled = twoFactorEnabled;
464+
return (U)this;
465+
}
466+
467+
@SuppressWarnings("unchecked")
468+
public U withUsername(String username) {
469+
this.username = username;
470+
return (U)this;
471+
}
472+
473+
@SuppressWarnings("unchecked")
474+
public U withWebsiteUrl(String websiteUrl) {
475+
this.websiteUrl = websiteUrl;
476+
return (U)this;
477+
}
478+
479+
@SuppressWarnings("unchecked")
480+
public U withWebUrl(String webUrl) {
481+
this.webUrl = webUrl;
482+
return (U)this;
483+
}
484+
485+
@SuppressWarnings("unchecked")
486+
public U withSkipConfirmation(Boolean skipConfirmation) {
487+
this.skipConfirmation = skipConfirmation;
488+
return (U)this;
489+
}
490+
491+
@SuppressWarnings("unchecked")
492+
public U withCustomAttributes(List<CustomAttribute> customAttributes) {
493+
this.customAttributes = customAttributes;
494+
return (U)this;
495+
}
303496
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
import javax.xml.bind.annotation.XmlRootElement;
55

66
@XmlRootElement
7-
public class Assignee extends AbstractUser {
7+
public class Assignee extends AbstractUser<Assignee> {
88
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
import javax.xml.bind.annotation.XmlRootElement;
55

66
@XmlRootElement
7-
public class Author extends AbstractUser {
7+
public class Author extends AbstractUser<Author> {
88
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
import javax.xml.bind.annotation.XmlRootElement;
44

55
@XmlRootElement
6-
public class Contributor extends AbstractUser {
6+
public class Contributor extends AbstractUser<Contributor> {
77
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
import javax.xml.bind.annotation.XmlRootElement;
44

55
@XmlRootElement
6-
public class Participant extends AbstractUser {
6+
public class Participant extends AbstractUser<Participant> {
77
}
Lines changed: 13 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package org.gitlab4j.api.models;
22

33
import javax.xml.bind.annotation.XmlRootElement;
4-
import java.util.List;
54

65
@XmlRootElement
7-
public class User extends AbstractUser {
6+
public class User extends AbstractUser<User> {
87
private String externUid;
98

109
public void setExternUid(String externUid) {
@@ -15,98 +14,27 @@ public String getExternUid() {
1514
return this.externUid;
1615
}
1716

18-
public User withEmail(String email) {
19-
setEmail(email);
20-
return this;
21-
}
22-
23-
public User withName(String name) {
24-
setName(name);
25-
return this;
26-
}
27-
28-
public User withUsername(String username) {
29-
setUsername(username);
30-
return this;
31-
}
32-
33-
public User withSkype(String skype) {
34-
setSkype(skype);
35-
return this;
36-
}
37-
38-
public User withLinkedin(String linkedIn) {
39-
setLinkedin(linkedIn);
40-
return this;
41-
}
42-
43-
public User withTwitter(String twitter) {
44-
setTwitter(twitter);
45-
return this;
46-
}
47-
48-
public User withWebsiteUrl(String websiteUrl) {
49-
setWebsiteUrl(websiteUrl);
50-
return this;
51-
}
52-
53-
public User withOrganization(String organization) {
54-
setOrganization(organization);
55-
return this;
56-
}
57-
17+
/**
18+
* @deprecated Replaced by {@link #withProjectsLimit(Integer)}
19+
* @see #withProjectsLimit(Integer)
20+
*/
21+
@Deprecated
5822
public User withProjectLimit(Integer projectsLimit) {
59-
setProjectsLimit(projectsLimit);
60-
return this;
23+
return withProjectsLimit(projectsLimit);
6124
}
6225

6326
public User withExternUid(String externUid) {
6427
setExternUid(externUid);
6528
return this;
6629
}
6730

68-
public User withProvider(String provider) {
69-
setProvider(provider);
70-
return this;
71-
}
72-
73-
public User withBio(String bio) {
74-
setBio(bio);
75-
return this;
76-
}
77-
78-
public User withLocation(String location) {
79-
setLocation(location);
80-
return this;
81-
}
82-
83-
public User withIsAdmin(Boolean isAdmin) {
84-
setIsAdmin(isAdmin);
85-
return this;
86-
}
87-
88-
public User withCanCreateGroup(Boolean canCreateGroup) {
89-
setCanCreateGroup(canCreateGroup);
90-
return this;
91-
}
92-
93-
public User withSkipConfirmation(Boolean skipConfirmation) {
94-
setSkipConfirmation(skipConfirmation);
95-
return this;
96-
}
97-
98-
public User withExternal(Boolean external) {
99-
setExternal(external);
100-
return this;
101-
}
102-
31+
/**
32+
* @deprecated Replaced by {@link #withSharedRunnersMinutesLimit(Integer)}
33+
* @see #withSharedRunnersMinutesLimit(Integer)
34+
*/
35+
@Deprecated
10336
public User withSharedRunnersMinuteLimit(Integer sharedRunnersMinuteLimit) {
104-
setSharedRunnersMinutesLimit(sharedRunnersMinuteLimit);
105-
return this;
37+
return withSharedRunnersMinutesLimit(sharedRunnersMinuteLimit);
10638
}
10739

108-
public User withCustomAttributes(List<CustomAttribute> customAttributes) {
109-
setCustomAttributes(customAttributes);
110-
return this;
111-
}
11240
}

0 commit comments

Comments
 (0)