Skip to content

Add withXxxxx() methods to AbstractUser #273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 194 additions & 1 deletion src/main/java/org/gitlab4j/api/models/AbstractUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@XmlAccessorType(XmlAccessType.FIELD)
@JsonIgnoreProperties(ignoreUnknown = true)
public class AbstractUser {
public abstract class AbstractUser<U extends AbstractUser<U>> {

private String avatarUrl;
private String bio;
Expand Down Expand Up @@ -300,4 +300,197 @@ public List<CustomAttribute> getCustomAttributes() {
public void setCustomAttributes(List<CustomAttribute> customAttributes) {
this.customAttributes = customAttributes;
}


@SuppressWarnings("unchecked")
public U withAvatarUrl(String avatarUrl) {
this.avatarUrl = avatarUrl;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withBio(String bio) {
this.bio = bio;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withCanCreateGroup(Boolean canCreateGroup) {
this.canCreateGroup = canCreateGroup;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withCanCreateProject(Boolean canCreateProject) {
this.canCreateProject = canCreateProject;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withColorSchemeId(Integer colorSchemeId) {
this.colorSchemeId = colorSchemeId;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withConfirmedAt(Date confirmedAt) {
this.confirmedAt = confirmedAt;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withCreatedAt(Date createdAt) {
this.createdAt = createdAt;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withCurrentSignInAt(Date currentSignInAt) {
this.currentSignInAt = currentSignInAt;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withEmail(String email) {
this.email = email;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withExternal(Boolean external) {
this.external = external;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withId(Integer id) {
this.id = id;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withIdentities(List<Identity> identities) {
this.identities = identities;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withIsAdmin(Boolean isAdmin) {
this.isAdmin = isAdmin;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withLastActivityOn(Date lastActivityOn) {
this.lastActivityOn = lastActivityOn;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withLastSignInAt(Date lastSignInAt) {
this.lastSignInAt = lastSignInAt;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withLinkedin(String linkedin) {
this.linkedin = linkedin;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withLocation(String location) {
this.location = location;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withName(String name) {
this.name = name;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withOrganization(String organization) {
this.organization = organization;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withProjectsLimit(Integer projectsLimit) {
this.projectsLimit = projectsLimit;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withProvider(String provider) {
this.provider = provider;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withSharedRunnersMinutesLimit(Integer sharedRunnersMinutesLimit) {
this.sharedRunnersMinutesLimit = sharedRunnersMinutesLimit;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withSkype(String skype) {
this.skype = skype;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withState(String state) {
this.state = state;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withThemeId(Integer themeId) {
this.themeId = themeId;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withTwitter(String twitter) {
this.twitter = twitter;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withTwoFactorEnabled(Boolean twoFactorEnabled) {
this.twoFactorEnabled = twoFactorEnabled;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withUsername(String username) {
this.username = username;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withWebsiteUrl(String websiteUrl) {
this.websiteUrl = websiteUrl;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withWebUrl(String webUrl) {
this.webUrl = webUrl;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withSkipConfirmation(Boolean skipConfirmation) {
this.skipConfirmation = skipConfirmation;
return (U)this;
}

@SuppressWarnings("unchecked")
public U withCustomAttributes(List<CustomAttribute> customAttributes) {
this.customAttributes = customAttributes;
return (U)this;
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/gitlab4j/api/models/Assignee.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Assignee extends AbstractUser {
public class Assignee extends AbstractUser<Assignee> {
}
2 changes: 1 addition & 1 deletion src/main/java/org/gitlab4j/api/models/Author.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Author extends AbstractUser {
public class Author extends AbstractUser<Author> {
}
2 changes: 1 addition & 1 deletion src/main/java/org/gitlab4j/api/models/Contributor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Contributor extends AbstractUser {
public class Contributor extends AbstractUser<Contributor> {
}
2 changes: 1 addition & 1 deletion src/main/java/org/gitlab4j/api/models/Participant.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Participant extends AbstractUser {
public class Participant extends AbstractUser<Participant> {
}
98 changes: 13 additions & 85 deletions src/main/java/org/gitlab4j/api/models/User.java
Original file line number Diff line number Diff line change
@@ -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<User> {
private String externUid;

public void setExternUid(String externUid) {
Expand All @@ -15,98 +14,27 @@ 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) {
setExternUid(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<CustomAttribute> customAttributes) {
setCustomAttributes(customAttributes);
return this;
}
}