3 * Copyright (C) 2009-2023 SonarSource SA
4 * mailto:info AT sonarsource DOT com
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.
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.
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.
20 package org.sonar.ce.task.projectanalysis.event;
22 import java.util.Objects;
23 import javax.annotation.Nullable;
24 import javax.annotation.concurrent.Immutable;
26 import static java.util.Objects.requireNonNull;
30 private final String name;
31 private final Category category;
33 private final String data;
35 private final String description;
37 private Event(String name, Category category, @Nullable String data, @Nullable String description) {
38 this.name = requireNonNull(name);
39 this.category = requireNonNull(category);
41 this.description = description;
44 private Event(String name, Category category) {
45 this.name = requireNonNull(name);
46 this.category = requireNonNull(category);
48 this.description = null;
51 public static Event createAlert(String name, @Nullable String data, @Nullable String description) {
52 return new Event(name, Category.ALERT, data, description);
55 public static Event createProfile(String name, @Nullable String data, @Nullable String description) {
56 return new Event(name, Category.PROFILE, data, description);
59 public static Event createIssueDetection(String name) {
60 return new Event(name, Category.ISSUE_DETECTION);
63 public String getName() {
67 public Category getCategory() {
71 public String getData() {
76 public String getDescription() {
81 public boolean equals(@Nullable Object o) {
85 if (o == null || getClass() != o.getClass()) {
88 Event event = (Event) o;
89 return Objects.equals(name, event.name) &&
90 Objects.equals(category, event.category);
94 public int hashCode() {
95 return Objects.hash(name, category);
98 public enum Category {
99 ALERT, PROFILE, ISSUE_DETECTION