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.

Organization.java 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 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.ce.task.projectanalysis.analysis;
  21. import javax.annotation.concurrent.Immutable;
  22. import org.sonar.db.organization.OrganizationDto;
  23. import static java.util.Objects.requireNonNull;
  24. @Immutable
  25. public class Organization {
  26. private final String uuid;
  27. private final String key;
  28. private final String name;
  29. private final String defaultQualityGateUuid;
  30. private Organization(String uuid, String key, String name, String defaultQualityGateUuid) {
  31. this.uuid = requireNonNull(uuid, "uuid can't be null");
  32. this.key = requireNonNull(key, "key can't be null");
  33. this.name = requireNonNull(name, "name can't be null");
  34. this.defaultQualityGateUuid = requireNonNull(defaultQualityGateUuid, "defaultQualityGateUuid can't be null");
  35. }
  36. public String getUuid() {
  37. return uuid;
  38. }
  39. public String getKey() {
  40. return key;
  41. }
  42. public String getName() {
  43. return name;
  44. }
  45. public String getDefaultQualityGateUuid() {
  46. return defaultQualityGateUuid;
  47. }
  48. @Override
  49. public boolean equals(Object o) {
  50. if (this == o) {
  51. return true;
  52. }
  53. if (o == null || getClass() != o.getClass()) {
  54. return false;
  55. }
  56. Organization that = (Organization) o;
  57. return uuid.equals(that.uuid);
  58. }
  59. @Override
  60. public int hashCode() {
  61. return uuid.hashCode();
  62. }
  63. @Override
  64. public String toString() {
  65. return "Organization{" +
  66. "uuid='" + uuid + '\'' +
  67. ", key='" + key + '\'' +
  68. ", name='" + name + '\'' +
  69. ", defaultQualityGateUuid='" + defaultQualityGateUuid + '\'' +
  70. '}';
  71. }
  72. public OrganizationDto toDto() {
  73. return new OrganizationDto()
  74. .setName(name)
  75. .setKey(key)
  76. .setUuid(uuid)
  77. .setDefaultQualityGateUuid(defaultQualityGateUuid);
  78. }
  79. public static Organization from(OrganizationDto organizationDto) {
  80. return new Organization(organizationDto.getUuid(), organizationDto.getKey(), organizationDto.getName(), organizationDto.getDefaultQualityGateUuid());
  81. }
  82. }