Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

DefaultOrganization.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2021 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.organization;
  21. import static java.util.Objects.requireNonNull;
  22. public class DefaultOrganization {
  23. private final String uuid;
  24. private final String key;
  25. private final String name;
  26. private final long createdAt;
  27. private final long updatedAt;
  28. private DefaultOrganization(Builder builder) {
  29. this.uuid = requireNonNull(builder.uuid, "uuid can't be null");
  30. this.key = requireNonNull(builder.key, "key can't be null");
  31. this.name = requireNonNull(builder.name, "name can't be null");
  32. this.createdAt = requireNonNull(builder.createdAt, "createdAt can't be null");
  33. this.updatedAt = requireNonNull(builder.updatedAt, "updatedAt can't be null");
  34. }
  35. public static Builder newBuilder() {
  36. return new Builder();
  37. }
  38. public String getUuid() {
  39. return uuid;
  40. }
  41. public String getKey() {
  42. return key;
  43. }
  44. public String getName() {
  45. return name;
  46. }
  47. public long getCreatedAt() {
  48. return createdAt;
  49. }
  50. public long getUpdatedAt() {
  51. return updatedAt;
  52. }
  53. @Override
  54. public String toString() {
  55. return "DefaultOrganization{" +
  56. "uuid='" + uuid + '\'' +
  57. ", key='" + key + '\'' +
  58. ", name='" + name + '\'' +
  59. ", createdAt=" + createdAt +
  60. ", updatedAt=" + updatedAt +
  61. '}';
  62. }
  63. public static final class Builder {
  64. private String uuid;
  65. private String key;
  66. private String name;
  67. private Long createdAt;
  68. private Long updatedAt;
  69. public Builder setUuid(String uuid) {
  70. this.uuid = uuid;
  71. return this;
  72. }
  73. public Builder setKey(String key) {
  74. this.key = key;
  75. return this;
  76. }
  77. public Builder setName(String name) {
  78. this.name = name;
  79. return this;
  80. }
  81. public Builder setCreatedAt(long createdAt) {
  82. this.createdAt = createdAt;
  83. return this;
  84. }
  85. public Builder setUpdatedAt(long updatedAt) {
  86. this.updatedAt = updatedAt;
  87. return this;
  88. }
  89. public DefaultOrganization build() {
  90. return new DefaultOrganization(this);
  91. }
  92. }
  93. }