aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-03-27 14:54:50 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2012-03-27 15:02:57 +0200
commit02627267d8d12b75b8df1ef0e744b47889b38c93 (patch)
tree0f977af13c91e427344f314638c3c64e71cc530e /sonar-server
parent9c834358db5dc7e944aa23f04ed50304a2913928 (diff)
downloadsonarqube-02627267d8d12b75b8df1ef0e744b47889b38c93.tar.gz
sonarqube-02627267d8d12b75b8df1ef0e744b47889b38c93.zip
SONAR-3323 rename @RequiredMeasures attributes to allOf and anyOf
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java4
-rw-r--r--sonar-server/src/main/java/org/sonar/server/ui/Views.java37
-rw-r--r--sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java6
3 files changed, 23 insertions, 24 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java b/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java
index eb8822713fa..6f3a41dbc7c 100644
--- a/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java
+++ b/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java
@@ -71,8 +71,8 @@ public class ViewProxy<V extends View> implements Comparable<ViewProxy> {
private void initRequiredMeasures(V view) {
RequiredMeasures requiredMeasuresAnnotation = AnnotationUtils.getClassAnnotation(view, RequiredMeasures.class);
if (requiredMeasuresAnnotation != null) {
- mandatoryMeasures = requiredMeasuresAnnotation.mandatory();
- needOneOfMeasures = requiredMeasuresAnnotation.oneOf();
+ mandatoryMeasures = requiredMeasuresAnnotation.allOf();
+ needOneOfMeasures = requiredMeasuresAnnotation.anyOf();
}
}
diff --git a/sonar-server/src/main/java/org/sonar/server/ui/Views.java b/sonar-server/src/main/java/org/sonar/server/ui/Views.java
index 73496c20c0d..f90787e60c7 100644
--- a/sonar-server/src/main/java/org/sonar/server/ui/Views.java
+++ b/sonar-server/src/main/java/org/sonar/server/ui/Views.java
@@ -19,27 +19,26 @@
*/
package org.sonar.server.ui;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import org.apache.commons.lang.ArrayUtils;
import org.sonar.api.ServerComponent;
import org.sonar.api.web.Page;
import org.sonar.api.web.View;
import org.sonar.api.web.Widget;
-import com.google.common.collect.Lists;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
public class Views implements ServerComponent {
- private Map<String, ViewProxy<Page>> pagesPerId = new HashMap<String, ViewProxy<Page>>();
- private Set<ViewProxy<Page>> pages = new TreeSet<ViewProxy<Page>>();
+ private Map<String, ViewProxy<Page>> pagesPerId = Maps.newHashMap();
+ private Set<ViewProxy<Page>> pages = Sets.newTreeSet();
- private Map<String, ViewProxy<Widget>> widgetsPerId = new HashMap<String, ViewProxy<Widget>>();
- private Set<ViewProxy<Widget>> widgets = new TreeSet<ViewProxy<Widget>>();
+ private Map<String, ViewProxy<Widget>> widgetsPerId = Maps.newHashMap();
+ private Set<ViewProxy<Widget>> widgets = Sets.newTreeSet();
public Views() {
}
@@ -85,7 +84,7 @@ public class Views implements ServerComponent {
}
public List<ViewProxy<Page>> getPagesForMetric(String section, String resourceScope, String resourceQualifier, String resourceLanguage,
- String[] availableMeasures, String metric) {
+ String[] availableMeasures, String metric) {
List<ViewProxy<Page>> result = Lists.newArrayList();
for (ViewProxy<Page> proxy : pages) {
if (accept(proxy, section, resourceScope, resourceQualifier, resourceLanguage, availableMeasures) && proxy.supportsMetric(metric)) {
@@ -115,22 +114,22 @@ public class Views implements ServerComponent {
protected static boolean accept(ViewProxy proxy, String section, String resourceScope, String resourceQualifier, String resourceLanguage, String[] availableMeasures) {
return acceptNavigationSection(proxy, section)
- && acceptResourceScope(proxy, resourceScope)
- && acceptResourceQualifier(proxy, resourceQualifier)
- && acceptResourceLanguage(proxy, resourceLanguage)
- && acceptAvailableMeasures(proxy, availableMeasures);
+ && acceptResourceScope(proxy, resourceScope)
+ && acceptResourceQualifier(proxy, resourceQualifier)
+ && acceptResourceLanguage(proxy, resourceLanguage)
+ && acceptAvailableMeasures(proxy, availableMeasures);
}
protected static boolean acceptResourceLanguage(ViewProxy proxy, String resourceLanguage) {
- return resourceLanguage== null || ArrayUtils.isEmpty(proxy.getResourceLanguages()) || ArrayUtils.contains(proxy.getResourceLanguages(), resourceLanguage);
+ return resourceLanguage == null || ArrayUtils.isEmpty(proxy.getResourceLanguages()) || ArrayUtils.contains(proxy.getResourceLanguages(), resourceLanguage);
}
protected static boolean acceptResourceScope(ViewProxy proxy, String resourceScope) {
- return resourceScope== null || ArrayUtils.isEmpty(proxy.getResourceScopes()) || ArrayUtils.contains(proxy.getResourceScopes(), resourceScope);
+ return resourceScope == null || ArrayUtils.isEmpty(proxy.getResourceScopes()) || ArrayUtils.contains(proxy.getResourceScopes(), resourceScope);
}
protected static boolean acceptResourceQualifier(ViewProxy proxy, String resourceQualifier) {
- return resourceQualifier== null || ArrayUtils.isEmpty(proxy.getResourceQualifiers()) || ArrayUtils.contains(proxy.getResourceQualifiers(), resourceQualifier);
+ return resourceQualifier == null || ArrayUtils.isEmpty(proxy.getResourceQualifiers()) || ArrayUtils.contains(proxy.getResourceQualifiers(), resourceQualifier);
}
protected static boolean acceptNavigationSection(ViewProxy proxy, String section) {
diff --git a/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java b/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java
index c2ae3c9d7ed..103fa41427d 100644
--- a/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java
@@ -155,7 +155,7 @@ public class ViewProxyTest {
@Test
public void shouldAcceptAvailableMeasuresForMandatoryMeasures() throws Exception {
- @RequiredMeasures(mandatory = {"lines", "ncloc"})
+ @RequiredMeasures(allOf = {"lines", "ncloc"})
class MyView extends FakeView {
MyView() {
super("fake");
@@ -169,7 +169,7 @@ public class ViewProxyTest {
@Test
public void shouldAcceptAvailableMeasuresForOneOfNeededMeasures() throws Exception {
- @RequiredMeasures(oneOf = {"lines", "ncloc"})
+ @RequiredMeasures(anyOf = {"lines", "ncloc"})
class MyView extends FakeView {
MyView() {
super("fake");
@@ -183,7 +183,7 @@ public class ViewProxyTest {
@Test
public void shouldAcceptAvailableMeasuresForMandatoryAndOneOfNeededMeasures() throws Exception {
- @RequiredMeasures(mandatory = {"lines", "ncloc"}, oneOf = {"duplications", "duplictated_blocks"})
+ @RequiredMeasures(allOf = {"lines", "ncloc"}, anyOf = {"duplications", "duplictated_blocks"})
class MyView extends FakeView {
MyView() {
super("fake");