44import java .io .IOException ;
55import java .util .Collection ;
66import java .util .Iterator ;
7+ import java .util .List ;
78import java .util .StringTokenizer ;
89
9- import org .apache .commons .collections .MultiMap ;
10- import org .apache .commons .collections .map .MultiValueMap ;
1110import org .eclipse .core .resources .IProject ;
1211import org .eclipse .jface .preference .IPersistentPreferenceStore ;
1312import org .eclipse .jface .preference .IPreferenceStore ;
1413
14+ import com .google .common .collect .LinkedListMultimap ;
15+ import com .google .common .collect .ListMultimap ;
16+
1517public class SuppressionProfile implements TableModel <Suppression > {
1618 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 ;
2122 private final IPreferenceStore projectPreferences ;
2223 private final IProject project ;
2324
2425 public SuppressionProfile (IPreferenceStore projectPreferences ,
2526 IProject project ) {
2627 this .projectPreferences = projectPreferences ;
27- this .suppressionList = new MultiValueMap ();
28+ this .suppressionList = LinkedListMultimap . create ();
2829 this .project = project ;
2930 load ();
3031 }
@@ -95,14 +96,9 @@ private File makeAbsoluteFile(File file) {
9596 }
9697
9798 public boolean isFileSuppressed (File file ) {
98- Collection <?> collection = ( Collection <?>) suppressionList
99+ List < Suppression > suppressions = suppressionList
99100 .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 ) {
106102 if (suppression .isFileSuppression ())
107103 return true ;
108104 }
@@ -115,15 +111,9 @@ public boolean isProblemInLineSuppressed(File file, String problemId,
115111 if (file == null ) {
116112 return false ;
117113 }
118- Collection <?> collection = ( Collection <?>) suppressionList
114+ List < Suppression > suppressions = suppressionList
119115 .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 ) {
127117 if (suppression .isFileSuppression ()) {
128118 return true ;
129119 }
@@ -134,16 +124,14 @@ public boolean isProblemInLineSuppressed(File file, String problemId,
134124 return false ;
135125 }
136126
137- public Collection <? > getSuppressions () {
127+ public Collection <Suppression > getSuppressions () {
138128 return suppressionList .values ();
139129 }
140130
141- @ SuppressWarnings ("unchecked" )
142131 public Iterator <Suppression > iterator () {
143132 return suppressionList .values ().iterator ();
144133 }
145134
146- @ SuppressWarnings ("unchecked" )
147135 public Suppression [] toArray () {
148136 return (Suppression []) suppressionList .values ().toArray (new Suppression [0 ]);
149137 }
0 commit comments