3 * Copyright (C) 2009-2019 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.qualitygate;
22 import javax.annotation.CheckForNull;
23 import javax.annotation.Nullable;
24 import javax.annotation.concurrent.Immutable;
26 import static com.google.common.base.Preconditions.checkArgument;
27 import static java.util.Objects.requireNonNull;
30 public class ConditionStatus {
31 public static final ConditionStatus NO_VALUE_STATUS = new ConditionStatus(EvaluationStatus.NO_VALUE, null);
33 private final EvaluationStatus status;
35 private final String value;
37 private ConditionStatus(EvaluationStatus status, @Nullable String value) {
38 this.status = requireNonNull(status, "status can not be null");
42 public static ConditionStatus create(EvaluationStatus status, String value) {
43 requireNonNull(status, "status can not be null");
44 checkArgument(status != EvaluationStatus.NO_VALUE, "EvaluationStatus 'NO_VALUE' can not be used with this method, use constant ConditionStatus.NO_VALUE_STATUS instead.");
45 requireNonNull(value, "value can not be null");
46 return new ConditionStatus(status, value);
49 public EvaluationStatus getStatus() {
54 * @return {@code null} when {@link #getStatus()} is {@link EvaluationStatus#NO_VALUE}, otherwise non {@code null}
57 public String getValue() {
62 public String toString() {
63 return "ConditionStatus{" +
65 ", value='" + value + '\'' +
69 public enum EvaluationStatus {
70 NO_VALUE, OK, WARN, ERROR