4
4
import java .io .IOException ;
5
5
import java .util .Collection ;
6
6
import java .util .Iterator ;
7
+ import java .util .List ;
7
8
import java .util .StringTokenizer ;
8
9
9
- import org .apache .commons .collections .MultiMap ;
10
- import org .apache .commons .collections .map .MultiValueMap ;
11
10
import org .eclipse .core .resources .IProject ;
12
11
import org .eclipse .jface .preference .IPersistentPreferenceStore ;
13
12
import org .eclipse .jface .preference .IPreferenceStore ;
14
13
14
+ import com .google .common .collect .LinkedListMultimap ;
15
+ import com .google .common .collect .ListMultimap ;
16
+
15
17
public class SuppressionProfile implements TableModel <Suppression > {
16
18
private static final String DELIMITER = "!" ;
17
- private final MultiMap suppressionList ; // this does not allow generics so
18
- // far,
19
- // contains File as key and Suppression
20
- // as value
19
+
20
+ // contains the suppressions per file
21
+ private final ListMultimap <File , Suppression > suppressionList ;
21
22
private final IPreferenceStore projectPreferences ;
22
23
private final IProject project ;
23
24
24
25
public SuppressionProfile (IPreferenceStore projectPreferences ,
25
26
IProject project ) {
26
27
this .projectPreferences = projectPreferences ;
27
- this .suppressionList = new MultiValueMap ();
28
+ this .suppressionList = LinkedListMultimap . create ();
28
29
this .project = project ;
29
30
load ();
30
31
}
@@ -95,14 +96,9 @@ private File makeAbsoluteFile(File file) {
95
96
}
96
97
97
98
public boolean isFileSuppressed (File file ) {
98
- Collection <?> collection = ( Collection <?>) suppressionList
99
+ List < Suppression > suppressions = suppressionList
99
100
.get (makeAbsoluteFile (file ));
100
- if (collection == null || collection .isEmpty ())
101
- return false ;
102
-
103
- Iterator <?> iterator = collection .iterator ();
104
- while (collection == null || iterator .hasNext ()) {
105
- Suppression suppression = (Suppression ) iterator .next ();
101
+ for (Suppression suppression : suppressions ) {
106
102
if (suppression .isFileSuppression ())
107
103
return true ;
108
104
}
@@ -115,15 +111,9 @@ public boolean isProblemInLineSuppressed(File file, String problemId,
115
111
if (file == null ) {
116
112
return false ;
117
113
}
118
- Collection <?> collection = ( Collection <?>) suppressionList
114
+ List < Suppression > suppressions = suppressionList
119
115
.get (makeAbsoluteFile (file ));
120
- if (collection == null || collection .isEmpty ()) {
121
- return false ;
122
- }
123
-
124
- Iterator <?> iterator = collection .iterator ();
125
- while (iterator .hasNext ()) {
126
- Suppression suppression = (Suppression ) iterator .next ();
116
+ for (Suppression suppression : suppressions ) {
127
117
if (suppression .isFileSuppression ()) {
128
118
return true ;
129
119
}
@@ -134,16 +124,14 @@ public boolean isProblemInLineSuppressed(File file, String problemId,
134
124
return false ;
135
125
}
136
126
137
- public Collection <? > getSuppressions () {
127
+ public Collection <Suppression > getSuppressions () {
138
128
return suppressionList .values ();
139
129
}
140
130
141
- @ SuppressWarnings ("unchecked" )
142
131
public Iterator <Suppression > iterator () {
143
132
return suppressionList .values ().iterator ();
144
133
}
145
134
146
- @ SuppressWarnings ("unchecked" )
147
135
public Suppression [] toArray () {
148
136
return (Suppression []) suppressionList .values ().toArray (new Suppression [0 ]);
149
137
}
0 commit comments