You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ComponentCreationParameters.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2024 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.server.common.component;
  21. import javax.annotation.Nullable;
  22. import org.sonar.db.project.CreationMethod;
  23. public record ComponentCreationParameters(NewComponent newComponent,
  24. @Nullable String userUuid,
  25. @Nullable String userLogin,
  26. @Nullable String mainBranchName,
  27. boolean isManaged,
  28. CreationMethod creationMethod) {
  29. public static ProjectCreationDataBuilder builder() {
  30. return new ProjectCreationDataBuilder();
  31. }
  32. public static final class ProjectCreationDataBuilder {
  33. private NewComponent newComponent;
  34. private String userUuid = null;
  35. private String userLogin = null;
  36. private String mainBranchName = null;
  37. private boolean isManaged = false;
  38. private CreationMethod creationMethod;
  39. public ProjectCreationDataBuilder newComponent(NewComponent newComponent) {
  40. this.newComponent = newComponent;
  41. return this;
  42. }
  43. public ProjectCreationDataBuilder userUuid(@Nullable String userUuid) {
  44. this.userUuid = userUuid;
  45. return this;
  46. }
  47. public ProjectCreationDataBuilder userLogin(@Nullable String userLogin) {
  48. this.userLogin = userLogin;
  49. return this;
  50. }
  51. public ProjectCreationDataBuilder mainBranchName(@Nullable String mainBranchName) {
  52. this.mainBranchName = mainBranchName;
  53. return this;
  54. }
  55. public ProjectCreationDataBuilder isManaged(boolean isManaged) {
  56. this.isManaged = isManaged;
  57. return this;
  58. }
  59. public ProjectCreationDataBuilder creationMethod(CreationMethod creationMethod) {
  60. this.creationMethod = creationMethod;
  61. return this;
  62. }
  63. public ComponentCreationParameters build() {
  64. return new ComponentCreationParameters(newComponent, userUuid, userLogin, mainBranchName, isManaged, creationMethod);
  65. }
  66. }
  67. }