org.sonar.server.user.UpdateUser Maven / Gradle / Ivy
/*
* SonarQube
* Copyright (C) 2009-2018 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.sonar.server.user;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
public class UpdateUser {
private String login;
private String name;
private String email;
private List scmAccounts;
private String password;
private ExternalIdentity externalIdentity;
private boolean nameChanged;
private boolean emailChanged;
private boolean scmAccountsChanged;
private boolean passwordChanged;
private boolean externalIdentityChanged;
private UpdateUser(String login) {
// No direct call to this constructor
this.login = login;
}
public String login() {
return login;
}
@CheckForNull
public String name() {
return name;
}
public UpdateUser setName(@Nullable String name) {
this.name = name;
nameChanged = true;
return this;
}
@CheckForNull
public String email() {
return email;
}
public UpdateUser setEmail(@Nullable String email) {
this.email = email;
emailChanged = true;
return this;
}
@CheckForNull
public List scmAccounts() {
return scmAccounts;
}
public UpdateUser setScmAccounts(@Nullable List scmAccounts) {
this.scmAccounts = scmAccounts;
scmAccountsChanged = true;
return this;
}
@CheckForNull
public String password() {
return password;
}
public UpdateUser setPassword(@Nullable String password) {
this.password = password;
passwordChanged = true;
return this;
}
@CheckForNull
public ExternalIdentity externalIdentity() {
return externalIdentity;
}
/**
* This method should only be used when updating a none local user
*/
public UpdateUser setExternalIdentity(@Nullable ExternalIdentity externalIdentity) {
this.externalIdentity = externalIdentity;
externalIdentityChanged = true;
return this;
}
public boolean isNameChanged() {
return nameChanged;
}
public boolean isEmailChanged() {
return emailChanged;
}
public boolean isScmAccountsChanged() {
return scmAccountsChanged;
}
public boolean isPasswordChanged() {
return passwordChanged;
}
public boolean isExternalIdentityChanged() {
return externalIdentityChanged;
}
public static UpdateUser create(String login) {
checkNotNull(login);
return new UpdateUser(login);
}
}