aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-02-03 21:50:16 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2013-02-03 21:57:31 +0100
commitbb0bcf4dfb1eef2ff42655d5e00b5d62c7bc4a6e (patch)
tree169215a45203a91ac63222278c3064d1307cfd75 /sonar-core
parentee051c0da6dbc967b50eee86bd906f372ad4e8bf (diff)
downloadsonarqube-bb0bcf4dfb1eef2ff42655d5e00b5d62c7bc4a6e.tar.gz
sonarqube-bb0bcf4dfb1eef2ff42655d5e00b5d62c7bc4a6e.zip
Remove some calls to commons-collections
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java25
1 files changed, 15 insertions, 10 deletions
diff --git a/sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java b/sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java
index ba2465fa101..180b163032b 100644
--- a/sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java
+++ b/sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java
@@ -19,12 +19,18 @@
*/
package org.sonar.jpa.dao;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.Predicate;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.measures.Metric;
-import java.util.*;
+import javax.annotation.Nullable;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
public class MeasuresDao extends BaseDao {
@@ -55,18 +61,17 @@ public class MeasuresDao extends BaseDao {
}
public Collection<Metric> getEnabledMetrics() {
- return CollectionUtils.select(getMetricsByName().values(), new Predicate() {
- public boolean evaluate(Object o) {
- return ((Metric) o).getEnabled();
+ return Collections2.filter(getMetricsByName().values(), new Predicate<Metric>() {
+ public boolean apply(@Nullable Metric o) {
+ return o != null && o.getEnabled();
}
});
}
public Collection<Metric> getUserDefinedMetrics() {
- return CollectionUtils.select(getMetricsByName().values(), new Predicate() {
- public boolean evaluate(Object o) {
- Metric m = (Metric) o;
- return (m.getEnabled() && m.getOrigin() != Metric.Origin.JAV);
+ return Collections2.filter(getMetricsByName().values(), new Predicate<Metric>() {
+ public boolean apply(@Nullable Metric metric) {
+ return metric != null && metric.getEnabled() && metric.getOrigin() != Metric.Origin.JAV;
}
});
}