001/*
002 * SonarQube
003 * Copyright (C) 2009-2017 SonarSource SA
004 * mailto:info AT sonarsource DOT com
005 *
006 * This program is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019 */
020package org.sonar.api.platform;
021
022import javax.annotation.Nullable;
023import org.sonar.api.ExtensionPoint;
024import org.sonar.api.server.ServerSide;
025
026import static java.util.Objects.requireNonNull;
027
028/**
029 * @since 3.2
030 */
031@ServerSide
032@ExtensionPoint
033public interface NewUserHandler {
034
035  final class Context {
036    private String login;
037    private String name;
038    private String email;
039
040    private Context(String login, String name, @Nullable String email) {
041      requireNonNull(login);
042      requireNonNull(name);
043      this.login = login;
044      this.name = name;
045      this.email = email;
046    }
047
048    public String getLogin() {
049      return login;
050    }
051
052    public String getName() {
053      return name;
054    }
055
056    public String getEmail() {
057      return email;
058    }
059
060    public static Builder builder() {
061      return new Builder();
062    }
063
064    public static final class Builder {
065      private String login;
066      private String name;
067      private String email;
068
069      private Builder() {
070      }
071
072      public Builder setLogin(String s) {
073        this.login = s;
074        return this;
075      }
076
077      public Builder setName(String s) {
078        this.name = s;
079        return this;
080      }
081
082      public Builder setEmail(@Nullable String s) {
083        this.email = s;
084        return this;
085      }
086
087      public Context build() {
088        return new Context(login, name, email);
089      }
090    }
091  }
092
093  void doOnNewUser(Context context);
094}