aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/main/java/org/sonar/api/web/Criterion.java
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-05-22 14:52:24 +0200
committerDavid Gageot <david@gageot.net>2012-05-22 14:52:24 +0200
commit777d9010c1f88229730db03e1e8636a39a207645 (patch)
treebd2d423b116a56fef710d425b6791aa1ae232902 /sonar-plugin-api/src/main/java/org/sonar/api/web/Criterion.java
parentfd7f6a27f9bfc895298a57be47fe7511d9d004b4 (diff)
downloadsonarqube-777d9010c1f88229730db03e1e8636a39a207645.tar.gz
sonarqube-777d9010c1f88229730db03e1e8636a39a207645.zip
SONAR-3016 More work on extension point for filter template
Introduce Criteria and FilterColums
Diffstat (limited to 'sonar-plugin-api/src/main/java/org/sonar/api/web/Criterion.java')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/Criterion.java107
1 files changed, 107 insertions, 0 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/Criterion.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/Criterion.java
new file mode 100644
index 00000000000..7142c745dd5
--- /dev/null
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/Criterion.java
@@ -0,0 +1,107 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.web;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+/**
+ * Definition of a criterion to be used to narrow down a {@see Filter}.
+ *
+ * @since 3.1
+ */
+public class Criterion {
+ public static final List<String> OPERATORS = ImmutableList.of("=", ">", "<", ">=", "<=");
+
+ private String family;
+ private String key;
+ private String operator;
+ private Float value;
+ private String textValue;
+ private boolean variation;
+
+ private Criterion() {
+ // The factory method should be used
+ }
+
+ /**
+ * Creates a new {@link Criterion}.
+ */
+ public static Criterion create() {
+ return new Criterion();
+ }
+
+ public String getFamily() {
+ return family;
+ }
+
+ public Criterion setFamily(String family) {
+ this.family = family;
+ return this;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public Criterion setKey(String key) {
+ this.key = key;
+ return this;
+ }
+
+ public String getOperator() {
+ return operator;
+ }
+
+ public Criterion setOperator(String operator) {
+ Preconditions.checkArgument(OPERATORS.contains(operator), "Valid operators are %s, not %s", OPERATORS, operator);
+ this.operator = operator;
+ return this;
+ }
+
+ public Float getValue() {
+ return value;
+ }
+
+ public Criterion setValue(Float value) {
+ this.value = value;
+ return this;
+ }
+
+ public String getTextValue() {
+ return textValue;
+ }
+
+ public Criterion setTextValue(String textValue) {
+ this.textValue = textValue;
+ return this;
+ }
+
+ public boolean isVariation() {
+ return variation;
+ }
+
+ public Criterion setVariation(boolean variation) {
+ this.variation = variation;
+ return this;
+ }
+}