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.projectexport.taskprocessor;
22 import java.util.Objects;
23 import javax.annotation.Nullable;
24 import javax.annotation.concurrent.Immutable;
25 import org.sonar.db.component.ComponentDto;
26 import org.sonar.db.project.ProjectDto;
28 import static java.util.Objects.requireNonNull;
31 public class ProjectDescriptor {
32 private final String uuid;
33 private final String key;
34 private final String name;
36 public ProjectDescriptor(String uuid, String key, String name) {
37 this.uuid = requireNonNull(uuid);
38 this.key = requireNonNull(key);
39 this.name = requireNonNull(name);
43 * Build a {@link ProjectDescriptor} without checking qualifier of ComponentDto.
45 public static ProjectDescriptor of(ProjectDto project) {
46 return new ProjectDescriptor(project.getUuid(), project.getKey(), project.getName());
49 public final String getUuid() {
53 public final String getKey() {
57 public final String getName() {
62 public final boolean equals(@Nullable Object o) {
66 if (o == null || getClass() != o.getClass()) {
69 ProjectDescriptor that = (ProjectDescriptor) o;
70 return key.equals(that.key);
74 public final int hashCode() {
75 return Objects.hash(key);
79 public final String toString() {
80 return getClass().getSimpleName() + "{" +
81 "uuid='" + uuid + '\'' +
82 ", key='" + key + '\'' +
83 ", name='" + name + '\'' +