From bee64b0bf1ca65621f99bc748aebbebad216f158 Mon Sep 17 00:00:00 2001 From: Michael Decker Date: Tue, 13 Nov 2018 16:23:47 +0100 Subject: [PATCH 1/2] Add with* methods to AbstractUser --- .../org/gitlab4j/api/models/AbstractUser.java | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) diff --git a/src/main/java/org/gitlab4j/api/models/AbstractUser.java b/src/main/java/org/gitlab4j/api/models/AbstractUser.java index a76c625bf..1590504f2 100644 --- a/src/main/java/org/gitlab4j/api/models/AbstractUser.java +++ b/src/main/java/org/gitlab4j/api/models/AbstractUser.java @@ -300,4 +300,165 @@ public List getCustomAttributes() { public void setCustomAttributes(List customAttributes) { this.customAttributes = customAttributes; } + + + public AbstractUser withAvatarUrl(String avatarUrl) { + this.avatarUrl = avatarUrl; + return this; + } + + public AbstractUser withBio(String bio) { + this.bio = bio; + return this; + } + + public AbstractUser withCanCreateGroup(Boolean canCreateGroup) { + this.canCreateGroup = canCreateGroup; + return this; + } + + public AbstractUser withCanCreateProject(Boolean canCreateProject) { + this.canCreateProject = canCreateProject; + return this; + } + + public AbstractUser withColorSchemeId(Integer colorSchemeId) { + this.colorSchemeId = colorSchemeId; + return this; + } + + public AbstractUser withConfirmedAt(Date confirmedAt) { + this.confirmedAt = confirmedAt; + return this; + } + + public AbstractUser withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public AbstractUser withCurrentSignInAt(Date currentSignInAt) { + this.currentSignInAt = currentSignInAt; + return this; + } + + public AbstractUser withEmail(String email) { + this.email = email; + return this; + } + + public AbstractUser withExternal(Boolean external) { + this.external = external; + return this; + } + + public AbstractUser withId(Integer id) { + this.id = id; + return this; + } + + public AbstractUser withIdentities(List identities) { + this.identities = identities; + return this; + } + + public AbstractUser withIsAdmin(Boolean isAdmin) { + this.isAdmin = isAdmin; + return this; + } + + public AbstractUser withLastActivityOn(Date lastActivityOn) { + this.lastActivityOn = lastActivityOn; + return this; + } + + public AbstractUser withLastSignInAt(Date lastSignInAt) { + this.lastSignInAt = lastSignInAt; + return this; + } + + public AbstractUser withLinkedin(String linkedin) { + this.linkedin = linkedin; + return this; + } + + public AbstractUser withLocation(String location) { + this.location = location; + return this; + } + + public AbstractUser withName(String name) { + this.name = name; + return this; + } + + public AbstractUser withOrganization(String organization) { + this.organization = organization; + return this; + } + + public AbstractUser withProjectsLimit(Integer projectsLimit) { + this.projectsLimit = projectsLimit; + return this; + } + + public AbstractUser withProvider(String provider) { + this.provider = provider; + return this; + } + + public AbstractUser withSharedRunnersMinutesLimit(Integer sharedRunnersMinutesLimit) { + this.sharedRunnersMinutesLimit = sharedRunnersMinutesLimit; + return this; + } + + public AbstractUser withSkype(String skype) { + this.skype = skype; + return this; + } + + public AbstractUser withState(String state) { + this.state = state; + return this; + } + + public AbstractUser withThemeId(Integer themeId) { + this.themeId = themeId; + return this; + } + + public AbstractUser withTwitter(String twitter) { + this.twitter = twitter; + return this; + } + + public AbstractUser withTwoFactorEnabled(Boolean twoFactorEnabled) { + this.twoFactorEnabled = twoFactorEnabled; + return this; + } + + public AbstractUser withUsername(String username) { + this.username = username; + return this; + } + + public AbstractUser withWebsiteUrl(String websiteUrl) { + this.websiteUrl = websiteUrl; + return this; + } + + public AbstractUser withWebUrl(String webUrl) { + this.webUrl = webUrl; + return this; + } + + public AbstractUser withSkipConfirmation(Boolean skipConfirmation) { + this.skipConfirmation = skipConfirmation; + return this; + } + + public AbstractUser withCustomAttributes(List customAttributes) { + this.customAttributes = customAttributes; + return this; + } } From 5dfb46a157d001c63b04d6590ccf0f52b11cf505 Mon Sep 17 00:00:00 2001 From: Michael Decker Date: Mon, 19 Nov 2018 12:50:50 +0100 Subject: [PATCH 2/2] With* of AbstractUser shall return the implementation type --- .../org/gitlab4j/api/models/AbstractUser.java | 162 +++++++++++------- .../org/gitlab4j/api/models/Assignee.java | 2 +- .../java/org/gitlab4j/api/models/Author.java | 2 +- .../org/gitlab4j/api/models/Contributor.java | 2 +- .../org/gitlab4j/api/models/Participant.java | 2 +- .../java/org/gitlab4j/api/models/User.java | 98 ++--------- 6 files changed, 114 insertions(+), 154 deletions(-) diff --git a/src/main/java/org/gitlab4j/api/models/AbstractUser.java b/src/main/java/org/gitlab4j/api/models/AbstractUser.java index 1590504f2..80ff36330 100644 --- a/src/main/java/org/gitlab4j/api/models/AbstractUser.java +++ b/src/main/java/org/gitlab4j/api/models/AbstractUser.java @@ -10,7 +10,7 @@ @XmlAccessorType(XmlAccessType.FIELD) @JsonIgnoreProperties(ignoreUnknown = true) -public class AbstractUser { +public abstract class AbstractUser> { private String avatarUrl; private String bio; @@ -302,163 +302,195 @@ public void setCustomAttributes(List customAttributes) { } - public AbstractUser withAvatarUrl(String avatarUrl) { + @SuppressWarnings("unchecked") + public U withAvatarUrl(String avatarUrl) { this.avatarUrl = avatarUrl; - return this; + return (U)this; } - public AbstractUser withBio(String bio) { + @SuppressWarnings("unchecked") + public U withBio(String bio) { this.bio = bio; - return this; + return (U)this; } - public AbstractUser withCanCreateGroup(Boolean canCreateGroup) { + @SuppressWarnings("unchecked") + public U withCanCreateGroup(Boolean canCreateGroup) { this.canCreateGroup = canCreateGroup; - return this; + return (U)this; } - public AbstractUser withCanCreateProject(Boolean canCreateProject) { + @SuppressWarnings("unchecked") + public U withCanCreateProject(Boolean canCreateProject) { this.canCreateProject = canCreateProject; - return this; + return (U)this; } - public AbstractUser withColorSchemeId(Integer colorSchemeId) { + @SuppressWarnings("unchecked") + public U withColorSchemeId(Integer colorSchemeId) { this.colorSchemeId = colorSchemeId; - return this; + return (U)this; } - public AbstractUser withConfirmedAt(Date confirmedAt) { + @SuppressWarnings("unchecked") + public U withConfirmedAt(Date confirmedAt) { this.confirmedAt = confirmedAt; - return this; + return (U)this; } - public AbstractUser withCreatedAt(Date createdAt) { + @SuppressWarnings("unchecked") + public U withCreatedAt(Date createdAt) { this.createdAt = createdAt; - return this; + return (U)this; } - public AbstractUser withCurrentSignInAt(Date currentSignInAt) { + @SuppressWarnings("unchecked") + public U withCurrentSignInAt(Date currentSignInAt) { this.currentSignInAt = currentSignInAt; - return this; + return (U)this; } - public AbstractUser withEmail(String email) { + @SuppressWarnings("unchecked") + public U withEmail(String email) { this.email = email; - return this; + return (U)this; } - public AbstractUser withExternal(Boolean external) { + @SuppressWarnings("unchecked") + public U withExternal(Boolean external) { this.external = external; - return this; + return (U)this; } - public AbstractUser withId(Integer id) { + @SuppressWarnings("unchecked") + public U withId(Integer id) { this.id = id; - return this; + return (U)this; } - public AbstractUser withIdentities(List identities) { + @SuppressWarnings("unchecked") + public U withIdentities(List identities) { this.identities = identities; - return this; + return (U)this; } - public AbstractUser withIsAdmin(Boolean isAdmin) { + @SuppressWarnings("unchecked") + public U withIsAdmin(Boolean isAdmin) { this.isAdmin = isAdmin; - return this; + return (U)this; } - public AbstractUser withLastActivityOn(Date lastActivityOn) { + @SuppressWarnings("unchecked") + public U withLastActivityOn(Date lastActivityOn) { this.lastActivityOn = lastActivityOn; - return this; + return (U)this; } - public AbstractUser withLastSignInAt(Date lastSignInAt) { + @SuppressWarnings("unchecked") + public U withLastSignInAt(Date lastSignInAt) { this.lastSignInAt = lastSignInAt; - return this; + return (U)this; } - public AbstractUser withLinkedin(String linkedin) { + @SuppressWarnings("unchecked") + public U withLinkedin(String linkedin) { this.linkedin = linkedin; - return this; + return (U)this; } - public AbstractUser withLocation(String location) { + @SuppressWarnings("unchecked") + public U withLocation(String location) { this.location = location; - return this; + return (U)this; } - public AbstractUser withName(String name) { + @SuppressWarnings("unchecked") + public U withName(String name) { this.name = name; - return this; + return (U)this; } - public AbstractUser withOrganization(String organization) { + @SuppressWarnings("unchecked") + public U withOrganization(String organization) { this.organization = organization; - return this; + return (U)this; } - public AbstractUser withProjectsLimit(Integer projectsLimit) { + @SuppressWarnings("unchecked") + public U withProjectsLimit(Integer projectsLimit) { this.projectsLimit = projectsLimit; - return this; + return (U)this; } - public AbstractUser withProvider(String provider) { + @SuppressWarnings("unchecked") + public U withProvider(String provider) { this.provider = provider; - return this; + return (U)this; } - public AbstractUser withSharedRunnersMinutesLimit(Integer sharedRunnersMinutesLimit) { + @SuppressWarnings("unchecked") + public U withSharedRunnersMinutesLimit(Integer sharedRunnersMinutesLimit) { this.sharedRunnersMinutesLimit = sharedRunnersMinutesLimit; - return this; + return (U)this; } - public AbstractUser withSkype(String skype) { + @SuppressWarnings("unchecked") + public U withSkype(String skype) { this.skype = skype; - return this; + return (U)this; } - public AbstractUser withState(String state) { + @SuppressWarnings("unchecked") + public U withState(String state) { this.state = state; - return this; + return (U)this; } - public AbstractUser withThemeId(Integer themeId) { + @SuppressWarnings("unchecked") + public U withThemeId(Integer themeId) { this.themeId = themeId; - return this; + return (U)this; } - public AbstractUser withTwitter(String twitter) { + @SuppressWarnings("unchecked") + public U withTwitter(String twitter) { this.twitter = twitter; - return this; + return (U)this; } - public AbstractUser withTwoFactorEnabled(Boolean twoFactorEnabled) { + @SuppressWarnings("unchecked") + public U withTwoFactorEnabled(Boolean twoFactorEnabled) { this.twoFactorEnabled = twoFactorEnabled; - return this; + return (U)this; } - public AbstractUser withUsername(String username) { + @SuppressWarnings("unchecked") + public U withUsername(String username) { this.username = username; - return this; + return (U)this; } - public AbstractUser withWebsiteUrl(String websiteUrl) { + @SuppressWarnings("unchecked") + public U withWebsiteUrl(String websiteUrl) { this.websiteUrl = websiteUrl; - return this; + return (U)this; } - public AbstractUser withWebUrl(String webUrl) { + @SuppressWarnings("unchecked") + public U withWebUrl(String webUrl) { this.webUrl = webUrl; - return this; + return (U)this; } - public AbstractUser withSkipConfirmation(Boolean skipConfirmation) { + @SuppressWarnings("unchecked") + public U withSkipConfirmation(Boolean skipConfirmation) { this.skipConfirmation = skipConfirmation; - return this; + return (U)this; } - public AbstractUser withCustomAttributes(List customAttributes) { + @SuppressWarnings("unchecked") + public U withCustomAttributes(List customAttributes) { this.customAttributes = customAttributes; - return this; + return (U)this; } } diff --git a/src/main/java/org/gitlab4j/api/models/Assignee.java b/src/main/java/org/gitlab4j/api/models/Assignee.java index 5125c2465..4163ad243 100644 --- a/src/main/java/org/gitlab4j/api/models/Assignee.java +++ b/src/main/java/org/gitlab4j/api/models/Assignee.java @@ -4,5 +4,5 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement -public class Assignee extends AbstractUser { +public class Assignee extends AbstractUser { } diff --git a/src/main/java/org/gitlab4j/api/models/Author.java b/src/main/java/org/gitlab4j/api/models/Author.java index 31ef9e8a7..679c5b174 100644 --- a/src/main/java/org/gitlab4j/api/models/Author.java +++ b/src/main/java/org/gitlab4j/api/models/Author.java @@ -4,5 +4,5 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement -public class Author extends AbstractUser { +public class Author extends AbstractUser { } diff --git a/src/main/java/org/gitlab4j/api/models/Contributor.java b/src/main/java/org/gitlab4j/api/models/Contributor.java index 17ccaa41a..44272c644 100644 --- a/src/main/java/org/gitlab4j/api/models/Contributor.java +++ b/src/main/java/org/gitlab4j/api/models/Contributor.java @@ -3,5 +3,5 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement -public class Contributor extends AbstractUser { +public class Contributor extends AbstractUser { } \ No newline at end of file diff --git a/src/main/java/org/gitlab4j/api/models/Participant.java b/src/main/java/org/gitlab4j/api/models/Participant.java index a4a06ba16..1c78d6cf5 100644 --- a/src/main/java/org/gitlab4j/api/models/Participant.java +++ b/src/main/java/org/gitlab4j/api/models/Participant.java @@ -3,5 +3,5 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement -public class Participant extends AbstractUser { +public class Participant extends AbstractUser { } \ No newline at end of file diff --git a/src/main/java/org/gitlab4j/api/models/User.java b/src/main/java/org/gitlab4j/api/models/User.java index 80e01713d..8d1c8098b 100644 --- a/src/main/java/org/gitlab4j/api/models/User.java +++ b/src/main/java/org/gitlab4j/api/models/User.java @@ -1,10 +1,9 @@ package org.gitlab4j.api.models; import javax.xml.bind.annotation.XmlRootElement; -import java.util.List; @XmlRootElement -public class User extends AbstractUser { +public class User extends AbstractUser { private String externUid; public void setExternUid(String externUid) { @@ -15,49 +14,13 @@ public String getExternUid() { return this.externUid; } - public User withEmail(String email) { - setEmail(email); - return this; - } - - public User withName(String name) { - setName(name); - return this; - } - - public User withUsername(String username) { - setUsername(username); - return this; - } - - public User withSkype(String skype) { - setSkype(skype); - return this; - } - - public User withLinkedin(String linkedIn) { - setLinkedin(linkedIn); - return this; - } - - public User withTwitter(String twitter) { - setTwitter(twitter); - return this; - } - - public User withWebsiteUrl(String websiteUrl) { - setWebsiteUrl(websiteUrl); - return this; - } - - public User withOrganization(String organization) { - setOrganization(organization); - return this; - } - + /** + * @deprecated Replaced by {@link #withProjectsLimit(Integer)} + * @see #withProjectsLimit(Integer) + */ + @Deprecated public User withProjectLimit(Integer projectsLimit) { - setProjectsLimit(projectsLimit); - return this; + return withProjectsLimit(projectsLimit); } public User withExternUid(String externUid) { @@ -65,48 +28,13 @@ public User withExternUid(String externUid) { return this; } - public User withProvider(String provider) { - setProvider(provider); - return this; - } - - public User withBio(String bio) { - setBio(bio); - return this; - } - - public User withLocation(String location) { - setLocation(location); - return this; - } - - public User withIsAdmin(Boolean isAdmin) { - setIsAdmin(isAdmin); - return this; - } - - public User withCanCreateGroup(Boolean canCreateGroup) { - setCanCreateGroup(canCreateGroup); - return this; - } - - public User withSkipConfirmation(Boolean skipConfirmation) { - setSkipConfirmation(skipConfirmation); - return this; - } - - public User withExternal(Boolean external) { - setExternal(external); - return this; - } - + /** + * @deprecated Replaced by {@link #withSharedRunnersMinutesLimit(Integer)} + * @see #withSharedRunnersMinutesLimit(Integer) + */ + @Deprecated public User withSharedRunnersMinuteLimit(Integer sharedRunnersMinuteLimit) { - setSharedRunnersMinutesLimit(sharedRunnersMinuteLimit); - return this; + return withSharedRunnersMinutesLimit(sharedRunnersMinuteLimit); } - public User withCustomAttributes(List customAttributes) { - setCustomAttributes(customAttributes); - return this; - } }