3 * Copyright (C) 2009-2017 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.server.computation.task.projectanalysis.component;
22 import java.util.EnumSet;
23 import java.util.List;
25 import javax.annotation.CheckForNull;
27 public interface Component {
29 PROJECT(0), MODULE(1), DIRECTORY(2), FILE(3), VIEW(0), SUBVIEW(1), PROJECT_VIEW(2);
31 private static final Set<Type> REPORT_TYPES = EnumSet.of(PROJECT, MODULE, DIRECTORY, FILE);
32 private static final Set<Type> VIEWS_TYPES = EnumSet.of(VIEW, SUBVIEW, PROJECT_VIEW);
34 private final int depth;
40 public int getDepth() {
44 public boolean isDeeperThan(Type otherType) {
45 return this.getDepth() > otherType.getDepth();
48 public boolean isHigherThan(Type otherType) {
49 return this.getDepth() < otherType.getDepth();
52 public boolean isReportType() {
53 return REPORT_TYPES.contains(this);
56 public boolean isViewsType() {
57 return VIEWS_TYPES.contains(this);
62 UNAVAILABLE, SAME, CHANGED, ADDED;
70 * Returns the component uuid
75 * Returns the component key <b>as defined in database</b>
76 * It may differ from keys listed in scanner report
77 * when analyzing a branch.
87 * The optional description of the component.
90 String getDescription();
92 List<Component> getChildren();
95 * Returns the attributes specific to components of type {@link Type#PROJECT}, {@link Type#MODULE},
96 * {@link Type#DIRECTORY} or {@link Type#FILE}.
98 * @throws IllegalStateException when the component's type is neither {@link Type#PROJECT}, {@link Type#MODULE},
99 * {@link Type#DIRECTORY} nor {@link Type#FILE}.
101 ReportAttributes getReportAttributes();
104 * The attributes of the Component if it's type is File.
106 * @throws IllegalStateException if the Component's type is not {@link Type#FILE}
108 FileAttributes getFileAttributes();
111 * The attributes of the Component if it's type is {@link Type#PROJECT_VIEW}.
113 * @throws IllegalStateException if the Component's type is not {@link Type#PROJECT_VIEW}
115 ProjectViewAttributes getProjectViewAttributes();
118 * The attributes of the Component if it's type is {@link Type#SUBVIEW}.
120 * @throws IllegalStateException if the Component's type is not {@link Type#SUBVIEW}
122 SubViewAttributes getSubViewAttributes();
125 * The attributes of the Component if it's type is {@link Type#VIEW}.
127 * @throws IllegalStateException if the Component's type is not {@link Type#VIEW}
129 ViewAttributes getViewAttributes();