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.

Analysis.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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.CheckForNull;
  22. import javax.annotation.Nullable;
  23. import javax.annotation.concurrent.Immutable;
  24. import static com.google.common.base.Preconditions.checkNotNull;
  25. @Immutable
  26. public class Analysis {
  27. private long id;
  28. private String uuid;
  29. private long createdAt;
  30. private Analysis(Builder builder) {
  31. this.id = builder.id;
  32. this.uuid = builder.uuid;
  33. this.createdAt = builder.createdAt;
  34. }
  35. public long getId() {
  36. return id;
  37. }
  38. public String getUuid() {
  39. return uuid;
  40. }
  41. public long getCreatedAt() {
  42. return createdAt;
  43. }
  44. public static final class Builder {
  45. @CheckForNull
  46. private Long id;
  47. @CheckForNull
  48. private String uuid;
  49. @CheckForNull
  50. private Long createdAt;
  51. public Builder setId(long id) {
  52. this.id = id;
  53. return this;
  54. }
  55. public Builder setUuid(String uuid) {
  56. this.uuid = uuid;
  57. return this;
  58. }
  59. public Builder setCreatedAt(long createdAt) {
  60. this.createdAt = createdAt;
  61. return this;
  62. }
  63. public Analysis build() {
  64. checkNotNull(id, "id cannot be null");
  65. checkNotNull(uuid, "uuid cannot be null");
  66. checkNotNull(createdAt, "createdAt cannot be null");
  67. return new Analysis(this);
  68. }
  69. }
  70. @Override
  71. public boolean equals(@Nullable Object o) {
  72. if (this == o) {
  73. return true;
  74. }
  75. if (o == null || getClass() != o.getClass()) {
  76. return false;
  77. }
  78. Analysis analysis = (Analysis) o;
  79. return id == analysis.id;
  80. }
  81. @Override
  82. public int hashCode() {
  83. return (int) (id ^ (id >>> 32));
  84. }
  85. @Override
  86. public String toString() {
  87. return "Analysis{" +
  88. "id=" + id +
  89. ", uuid='" + uuid + '\'' +
  90. ", createdAt=" + createdAt +
  91. '}';
  92. }
  93. }