Improved code: fixed usage of raw types (except Commons Collections) and converted use of Iterator to for-each loop
git-svn-id: https://svn.apache.org/repos/asf/maven/shared/trunk@1762213 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java b/src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java
index 14b0728..01de394 100644
--- a/src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java
+++ b/src/main/java/org/apache/maven/shared/jar/JarAnalyzer.java
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.Iterator;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
@@ -113,16 +112,13 @@
}
// Obtain entries list.
- List entries = Collections.list( jarFile.entries() );
+ List<JarEntry> entries = Collections.list( jarFile.entries() );
// Sorting of list is done by name to ensure a bytecode hash is always consistent.
- Collections.sort( entries, new Comparator()
+ Collections.sort( entries, new Comparator<JarEntry>()
{
- public int compare( Object o1, Object o2 )
+ public int compare( JarEntry entry1, JarEntry entry2 )
{
- JarEntry entry1 = (JarEntry) o1;
- JarEntry entry2 = (JarEntry) o2;
-
return entry1.getName().compareTo( entry2.getName() );
}
} );
@@ -175,15 +171,12 @@
* @param pattern the pattern to filter against
* @return the list of files found, in {@link java.util.jar.JarEntry} elements
*/
- public List filterEntries( Pattern pattern )
+ public List<JarEntry> filterEntries( Pattern pattern )
{
- List ret = new ArrayList();
+ List<JarEntry> ret = new ArrayList<JarEntry>();
- Iterator it = getEntries().iterator();
- while ( it.hasNext() )
+ for ( JarEntry entry : getEntries() )
{
- JarEntry entry = (JarEntry) it.next();
-
Matcher mat = pattern.matcher( entry.getName() );
if ( mat.find() )
{
@@ -198,7 +191,7 @@
*
* @return the list of files found, in {@link java.util.jar.JarEntry} elements
*/
- public List getClassEntries()
+ public List<JarEntry> getClassEntries()
{
return filterEntries( CLASS_FILTER );
}
@@ -208,7 +201,7 @@
*
* @return the list of files found, in {@link java.util.jar.JarEntry} elements
*/
- public List getMavenPomEntries()
+ public List<JarEntry> getMavenPomEntries()
{
return filterEntries( MAVEN_POM_FILTER );
}
@@ -218,7 +211,7 @@
*
* @return the list of files found, in {@link java.util.jar.JarEntry} elements
*/
- public List getVersionEntries()
+ public List<JarEntry> getVersionEntries()
{
return filterEntries( VERSION_FILTER );
}
@@ -228,7 +221,7 @@
*
* @return the list of files found, in {@link java.util.jar.JarEntry} elements
*/
- public List getEntries()
+ public List<JarEntry> getEntries()
{
return jarData.getEntries();
}
diff --git a/src/main/java/org/apache/maven/shared/jar/JarData.java b/src/main/java/org/apache/maven/shared/jar/JarData.java
index ba9ab30..faf7220 100644
--- a/src/main/java/org/apache/maven/shared/jar/JarData.java
+++ b/src/main/java/org/apache/maven/shared/jar/JarData.java
@@ -27,6 +27,7 @@
import java.util.Collections;
import java.util.List;
import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
import java.util.jar.Manifest;
/**
@@ -67,7 +68,7 @@
/**
* The JAR entries.
*/
- private final List entries;
+ private final List<JarEntry> entries;
/**
* Information about the JAR's identifying features.
@@ -81,7 +82,7 @@
* @param manifest the JAR manifest
* @param entries the JAR entries
*/
- public JarData( File file, Manifest manifest, List entries )
+ public JarData( File file, Manifest manifest, List<JarEntry> entries )
{
this.file = file;
@@ -101,7 +102,7 @@
this.sealed = sealed;
}
- public List getEntries()
+ public List<JarEntry> getEntries()
{
return entries;
}
diff --git a/src/main/java/org/apache/maven/shared/jar/classes/ImportVisitor.java b/src/main/java/org/apache/maven/shared/jar/classes/ImportVisitor.java
index acb5457..6f78bb6 100644
--- a/src/main/java/org/apache/maven/shared/jar/classes/ImportVisitor.java
+++ b/src/main/java/org/apache/maven/shared/jar/classes/ImportVisitor.java
@@ -39,7 +39,7 @@
/**
* The list of imports discovered.
*/
- private List imports;
+ private List<String> imports;
/**
* The Java class that is being analyzed.
@@ -68,7 +68,7 @@
// Create a list that is guaranteed to be unique while retaining it's list qualities (LinkedHashSet does not
// expose the list interface even if natural ordering is retained)
- this.imports = SetUniqueList.decorate( new ArrayList() );
+ this.imports = SetUniqueList.decorate( new ArrayList<String>() );
}
/**
@@ -76,7 +76,7 @@
*
* @return Returns the imports.
*/
- public List getImports()
+ public List<String> getImports()
{
return imports;
}
diff --git a/src/main/java/org/apache/maven/shared/jar/classes/JarClasses.java b/src/main/java/org/apache/maven/shared/jar/classes/JarClasses.java
index b956d67..b17298e 100644
--- a/src/main/java/org/apache/maven/shared/jar/classes/JarClasses.java
+++ b/src/main/java/org/apache/maven/shared/jar/classes/JarClasses.java
@@ -35,22 +35,22 @@
/**
* The list of imports in the classes in the JAR.
*/
- private List imports;
+ private List<String> imports;
/**
* A list of packages represented by classes in the JAR.
*/
- private List packages;
+ private List<String> packages;
/**
* A list of the classes that in the JAR.
*/
- private List classNames;
+ private List<String> classNames;
/**
* A list of methods within the classes in the JAR.
*/
- private List methods;
+ private List<String> methods;
/**
* Whether the JAR contains any code with debug information. If there is a mix of debug and release code, this will
@@ -71,10 +71,10 @@
{
// Unique list decorators are used to ensure natural ordering is retained, the list interface is availble, and
// that duplicates are not entered.
- imports = SetUniqueList.decorate( new ArrayList() );
- packages = SetUniqueList.decorate( new ArrayList() );
- classNames = SetUniqueList.decorate( new ArrayList() );
- methods = SetUniqueList.decorate( new ArrayList() );
+ imports = SetUniqueList.decorate( new ArrayList<String>() );
+ packages = SetUniqueList.decorate( new ArrayList<String>() );
+ classNames = SetUniqueList.decorate( new ArrayList<String>() );
+ methods = SetUniqueList.decorate( new ArrayList<String>() );
}
/**
@@ -112,22 +112,22 @@
*
* @param imports the imports to add. Each item should be a String to avoid down the line ClassCastExceptions.
*/
- public void addImports( List imports )
+ public void addImports( List<String> imports )
{
this.imports.addAll( imports );
}
- public List getImports()
+ public List<String> getImports()
{
return Collections.unmodifiableList( imports );
}
- public List getClassNames()
+ public List<String> getClassNames()
{
return Collections.unmodifiableList( classNames );
}
- public List getPackages()
+ public List<String> getPackages()
{
return Collections.unmodifiableList( packages );
}
@@ -152,7 +152,7 @@
this.jdkRevision = jdkRevision;
}
- public List getMethods()
+ public List<String> getMethods()
{
return Collections.unmodifiableList( methods );
}
diff --git a/src/main/java/org/apache/maven/shared/jar/classes/JarClassesAnalysis.java b/src/main/java/org/apache/maven/shared/jar/classes/JarClassesAnalysis.java
index 8931ab0..e0a92cc 100644
--- a/src/main/java/org/apache/maven/shared/jar/classes/JarClassesAnalysis.java
+++ b/src/main/java/org/apache/maven/shared/jar/classes/JarClassesAnalysis.java
@@ -29,7 +29,6 @@
import org.codehaus.plexus.logging.AbstractLogEnabled;
import java.io.IOException;
-import java.util.Iterator;
import java.util.List;
import java.util.jar.JarEntry;
@@ -77,16 +76,14 @@
String jarfilename = jarAnalyzer.getFile().getAbsolutePath();
classes = new JarClasses();
- List classList = jarAnalyzer.getClassEntries();
+ List<JarEntry> classList = jarAnalyzer.getClassEntries();
classes.setDebugPresent( false );
double maxVersion = 0.0;
- Iterator it = classList.iterator();
- while ( it.hasNext() )
+ for ( JarEntry entry : classList )
{
- JarEntry entry = (JarEntry) it.next();
String classname = entry.getName();
try
diff --git a/src/main/java/org/apache/maven/shared/jar/identification/JarIdentification.java b/src/main/java/org/apache/maven/shared/jar/identification/JarIdentification.java
index 97025d1..7a01a51 100644
--- a/src/main/java/org/apache/maven/shared/jar/identification/JarIdentification.java
+++ b/src/main/java/org/apache/maven/shared/jar/identification/JarIdentification.java
@@ -57,27 +57,27 @@
/**
* The list of possible group IDs discovered.
*/
- private List potentialGroupIds = new ArrayList();
+ private List<String> potentialGroupIds = new ArrayList<String>();
/**
* The list of possible artifact IDs discovered.
*/
- private List potentialArtifactIds = new ArrayList();
+ private List<String> potentialArtifactIds = new ArrayList<String>();
/**
* The list of possible versions discovered.
*/
- private List potentialVersions = new ArrayList();
+ private List<String> potentialVersions = new ArrayList<String>();
/**
* The list of possible artifact names discovered.
*/
- private List potentialNames = new ArrayList();
+ private List<String> potentialNames = new ArrayList<String>();
/**
* The list of possible vendors discovered.
*/
- private List potentialVendors = new ArrayList();
+ private List<String> potentialVendors = new ArrayList<String>();
/**
* Add a validated group ID.
@@ -204,7 +204,7 @@
addUnique( potentialNames, name );
}
- private static void addUnique( List list, String value )
+ private static void addUnique( List<String> list, String value )
{
if ( value != null )
{
@@ -265,27 +265,27 @@
this.version = version;
}
- public List getPotentialVersions()
+ public List<String> getPotentialVersions()
{
return potentialVersions;
}
- public List getPotentialNames()
+ public List<String> getPotentialNames()
{
return potentialNames;
}
- public List getPotentialGroupIds()
+ public List<String> getPotentialGroupIds()
{
return potentialGroupIds;
}
- public List getPotentialArtifactIds()
+ public List<String> getPotentialArtifactIds()
{
return potentialArtifactIds;
}
- public List getPotentialVendors()
+ public List<String> getPotentialVendors()
{
return potentialVendors;
}
diff --git a/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationAnalysis.java b/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationAnalysis.java
index 88cf140..cd01b3e 100644
--- a/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationAnalysis.java
+++ b/src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationAnalysis.java
@@ -23,7 +23,6 @@
import org.apache.maven.shared.utils.StringUtils;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
/**
@@ -47,7 +46,7 @@
*
* @plexus.requirement role="org.apache.maven.shared.jar.identification.JarIdentificationExposer"
*/
- private List exposers;
+ private List<JarIdentificationExposer> exposers;
/**
* Analyze a JAR and find any associated Maven metadata. Note that if the provided JAR analyzer has previously
@@ -67,9 +66,8 @@
taxon = new JarIdentification();
- for ( Iterator i = exposers.iterator(); i.hasNext(); )
+ for ( JarIdentificationExposer exposer : exposers )
{
- JarIdentificationExposer exposer = (JarIdentificationExposer) i.next();
exposer.expose( taxon, jarAnalyzer );
}
@@ -108,56 +106,45 @@
}
}
- private String pickSmallest( List list )
+ private String pickSmallest( List<String> list )
{
String smallest = null;
- if ( !list.isEmpty() )
+ int size = Integer.MAX_VALUE;
+ for ( String val : list )
{
- int size = Integer.MAX_VALUE;
- Iterator it = list.iterator();
- while ( it.hasNext() )
+ if ( StringUtils.isNotEmpty( val ) )
{
- String val = (String) it.next();
-
- if ( StringUtils.isNotEmpty( val ) )
+ if ( val.length() < size )
{
- if ( val.length() < size )
- {
- smallest = val;
- size = val.length();
- }
+ smallest = val;
+ size = val.length();
}
}
}
-
+
return smallest;
}
- private String pickLargest( List list )
+ private String pickLargest( List<String> list )
{
String largest = null;
- if ( !list.isEmpty() )
+ int size = Integer.MIN_VALUE;
+ for ( String val : list )
{
- int size = Integer.MIN_VALUE;
- Iterator it = list.iterator();
- while ( it.hasNext() )
+ if ( StringUtils.isNotEmpty( val ) )
{
- String val = (String) it.next();
- if ( StringUtils.isNotEmpty( val ) )
+ if ( val.length() > size )
{
- if ( val.length() > size )
- {
- largest = val;
- size = val.length();
- }
+ largest = val;
+ size = val.length();
}
}
}
return largest;
}
- public void setExposers( List exposers )
+ public void setExposers( List<JarIdentificationExposer> exposers )
{
this.exposers = Collections.unmodifiableList( exposers );
}
diff --git a/src/main/java/org/apache/maven/shared/jar/identification/exposers/EmbeddedMavenModelExposer.java b/src/main/java/org/apache/maven/shared/jar/identification/exposers/EmbeddedMavenModelExposer.java
index 54632d6..380b92f 100644
--- a/src/main/java/org/apache/maven/shared/jar/identification/exposers/EmbeddedMavenModelExposer.java
+++ b/src/main/java/org/apache/maven/shared/jar/identification/exposers/EmbeddedMavenModelExposer.java
@@ -47,7 +47,7 @@
{
public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer )
{
- List entries = jarAnalyzer.getMavenPomEntries();
+ List<JarEntry> entries = jarAnalyzer.getMavenPomEntries();
if ( entries.isEmpty() )
{
return;
diff --git a/src/main/java/org/apache/maven/shared/jar/identification/exposers/JarClassesExposer.java b/src/main/java/org/apache/maven/shared/jar/identification/exposers/JarClassesExposer.java
index 2da4cce..0948e70 100644
--- a/src/main/java/org/apache/maven/shared/jar/identification/exposers/JarClassesExposer.java
+++ b/src/main/java/org/apache/maven/shared/jar/identification/exposers/JarClassesExposer.java
@@ -25,9 +25,6 @@
import org.apache.maven.shared.jar.identification.JarIdentification;
import org.apache.maven.shared.jar.identification.JarIdentificationExposer;
-import java.util.Iterator;
-
-
/**
* Exposer that examines a JAR file to derive Maven metadata from the classes in a JAR. It will currently identify
* potential group IDs from the class packages.
@@ -49,10 +46,8 @@
{
JarClasses jarclasses = analyzer.analyze( jarAnalyzer );
- Iterator it = jarclasses.getPackages().iterator();
- while ( it.hasNext() )
+ for ( String packagename : jarclasses.getPackages() )
{
- String packagename = (String) it.next();
identification.addGroupId( packagename );
}
}
diff --git a/src/main/java/org/apache/maven/shared/jar/identification/exposers/ManifestExposer.java b/src/main/java/org/apache/maven/shared/jar/identification/exposers/ManifestExposer.java
index c8de717..4817f71 100644
--- a/src/main/java/org/apache/maven/shared/jar/identification/exposers/ManifestExposer.java
+++ b/src/main/java/org/apache/maven/shared/jar/identification/exposers/ManifestExposer.java
@@ -23,8 +23,6 @@
import org.apache.maven.shared.jar.identification.JarIdentification;
import org.apache.maven.shared.jar.identification.JarIdentificationExposer;
-import java.util.Iterator;
-import java.util.Map;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
@@ -43,13 +41,8 @@
{
addManifestAttributeValues( manifest.getMainAttributes(), identification );
- Map entries = manifest.getEntries();
- Iterator itentries = entries.entrySet().iterator();
- while ( itentries.hasNext() )
+ for ( Attributes attribs : manifest.getEntries().values() )
{
- Map.Entry entry = (Map.Entry) itentries.next();
- Attributes attribs = (Attributes) entry.getValue();
-
addManifestAttributeValues( attribs, identification );
}
}
diff --git a/src/main/java/org/apache/maven/shared/jar/identification/exposers/RepositorySearchExposer.java b/src/main/java/org/apache/maven/shared/jar/identification/exposers/RepositorySearchExposer.java
index becb8a6..a40efc1 100644
--- a/src/main/java/org/apache/maven/shared/jar/identification/exposers/RepositorySearchExposer.java
+++ b/src/main/java/org/apache/maven/shared/jar/identification/exposers/RepositorySearchExposer.java
@@ -28,7 +28,6 @@
import org.codehaus.plexus.logging.AbstractLogEnabled;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
/**
@@ -71,7 +70,7 @@
public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer )
{
- List repohits = new ArrayList();
+ List<Artifact> repohits = new ArrayList<Artifact>();
String hash = fileHashAnalyzer.computeHash( jarAnalyzer );
if ( hash != null )
@@ -85,17 +84,12 @@
repohits.addAll( repositoryHashSearch.searchBytecodeHash( bytecodehash ) );
}
- if ( !repohits.isEmpty() )
+ // Found hits in the repository.
+ for ( Artifact artifact : repohits )
{
- // Found hits in the repository.
- Iterator it = repohits.iterator();
- while ( it.hasNext() )
- {
- Artifact artifact = (Artifact) it.next();
- identification.addAndSetGroupId( artifact.getGroupId() );
- identification.addAndSetArtifactId( artifact.getArtifactId() );
- identification.addAndSetVersion( artifact.getVersion() );
- }
+ identification.addAndSetGroupId( artifact.getGroupId() );
+ identification.addAndSetArtifactId( artifact.getArtifactId() );
+ identification.addAndSetVersion( artifact.getVersion() );
}
}
diff --git a/src/main/java/org/apache/maven/shared/jar/identification/exposers/StaticMainOutputExposer.java b/src/main/java/org/apache/maven/shared/jar/identification/exposers/StaticMainOutputExposer.java
index 4eda924..ddd0aea 100644
--- a/src/main/java/org/apache/maven/shared/jar/identification/exposers/StaticMainOutputExposer.java
+++ b/src/main/java/org/apache/maven/shared/jar/identification/exposers/StaticMainOutputExposer.java
@@ -24,7 +24,6 @@
import org.apache.maven.shared.jar.identification.JarIdentificationExposer;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
/**
@@ -40,21 +39,16 @@
{
public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer )
{
- List staticMains = findStaticMainVersions();
- if ( !staticMains.isEmpty() )
+ List<String> staticMains = findStaticMainVersions();
+ for ( String ver : staticMains )
{
- Iterator itvers = staticMains.iterator();
- while ( itvers.hasNext() )
- {
- String ver = (String) itvers.next();
- identification.addVersion( ver );
- }
+ identification.addVersion( ver );
}
}
- private List findStaticMainVersions()
+ private List<String> findStaticMainVersions()
{
// TODO: Execute the static main methods of classes with 'Version' in their name.
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
}
diff --git a/src/main/java/org/apache/maven/shared/jar/identification/exposers/TextFileExposer.java b/src/main/java/org/apache/maven/shared/jar/identification/exposers/TextFileExposer.java
index adcb410..ade4639 100644
--- a/src/main/java/org/apache/maven/shared/jar/identification/exposers/TextFileExposer.java
+++ b/src/main/java/org/apache/maven/shared/jar/identification/exposers/TextFileExposer.java
@@ -31,7 +31,6 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.jar.JarEntry;
@@ -48,28 +47,20 @@
{
public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer )
{
- List textFiles = findTextFileVersions( jarAnalyzer );
- if ( !textFiles.isEmpty() )
+ List<String> textFiles = findTextFileVersions( jarAnalyzer );
+ for ( String ver : textFiles )
{
- Iterator ithits = textFiles.iterator();
- while ( ithits.hasNext() )
- {
- String ver = (String) ithits.next();
- identification.addVersion( ver );
- }
+ identification.addVersion( ver );
}
}
- private List findTextFileVersions( JarAnalyzer jarAnalyzer )
+ private List<String> findTextFileVersions( JarAnalyzer jarAnalyzer )
{
- List textVersions = new ArrayList();
- List hits = jarAnalyzer.getVersionEntries();
+ List<String> textVersions = new ArrayList<String>();
+ List<JarEntry> hits = jarAnalyzer.getVersionEntries();
- Iterator it = hits.iterator();
- while ( it.hasNext() )
+ for ( JarEntry entry : hits )
{
- JarEntry entry = (JarEntry) it.next();
-
// skip this entry if it's a class file.
if ( !entry.getName().endsWith( ".class" ) ) //$NON-NLS-1$
{
diff --git a/src/main/java/org/apache/maven/shared/jar/identification/exposers/TimestampExposer.java b/src/main/java/org/apache/maven/shared/jar/identification/exposers/TimestampExposer.java
index 4badf90..5443985 100644
--- a/src/main/java/org/apache/maven/shared/jar/identification/exposers/TimestampExposer.java
+++ b/src/main/java/org/apache/maven/shared/jar/identification/exposers/TimestampExposer.java
@@ -28,7 +28,6 @@
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.jar.JarEntry;
@@ -43,28 +42,24 @@
{
public void expose( JarIdentification identification, JarAnalyzer jarAnalyzer )
{
- List entries = jarAnalyzer.getEntries();
+ List<JarEntry> entries = jarAnalyzer.getEntries();
SimpleDateFormat tsformat = new SimpleDateFormat( "yyyyMMdd", Locale.US ); //$NON-NLS-1$
Bag timestamps = new HashBag();
- Iterator it = entries.iterator();
- while ( it.hasNext() )
+ for ( JarEntry entry : entries )
{
- JarEntry entry = (JarEntry) it.next();
long time = entry.getTime();
String timestamp = tsformat.format( new Date( time ) );
timestamps.add( timestamp );
}
- it = timestamps.iterator();
String ts = "";
int tsmax = 0;
- while ( it.hasNext() )
+ for ( Object timestamp : timestamps )
{
- String timestamp = (String) it.next();
int count = timestamps.getCount( timestamp );
if ( count > tsmax )
{
- ts = timestamp;
+ ts = (String) timestamp;
tsmax = count;
}
}
diff --git a/src/main/java/org/apache/maven/shared/jar/identification/hash/JarBytecodeHashAnalyzer.java b/src/main/java/org/apache/maven/shared/jar/identification/hash/JarBytecodeHashAnalyzer.java
index 2eeecfa..8db7a6b 100644
--- a/src/main/java/org/apache/maven/shared/jar/identification/hash/JarBytecodeHashAnalyzer.java
+++ b/src/main/java/org/apache/maven/shared/jar/identification/hash/JarBytecodeHashAnalyzer.java
@@ -28,7 +28,7 @@
import java.io.IOException;
import java.io.InputStream;
-import java.util.Iterator;
+import java.util.List;
import java.util.jar.JarEntry;
/**
@@ -58,14 +58,13 @@
String result = jarData.getBytecodeHash();
if ( result == null )
{
- Iterator it = jarAnalyzer.getClassEntries().iterator();
+ List<JarEntry> entries = jarAnalyzer.getClassEntries();
try
{
digester.reset();
- while ( it.hasNext() )
+ for ( JarEntry entry : entries )
{
- JarEntry entry = (JarEntry) it.next();
computeEntryBytecodeHash( jarAnalyzer.getEntryInputStream( entry ) );
}
result = digester.calc();
diff --git a/src/main/java/org/apache/maven/shared/jar/identification/repository/EmptyRepositoryHashSearch.java b/src/main/java/org/apache/maven/shared/jar/identification/repository/EmptyRepositoryHashSearch.java
index 8e8f4a6..1f3b9f1 100644
--- a/src/main/java/org/apache/maven/shared/jar/identification/repository/EmptyRepositoryHashSearch.java
+++ b/src/main/java/org/apache/maven/shared/jar/identification/repository/EmptyRepositoryHashSearch.java
@@ -22,6 +22,8 @@
import java.util.Collections;
import java.util.List;
+import org.apache.maven.artifact.Artifact;
+
/**
* Empty repository hash search. Always returns an empty list.
* <p/>
@@ -34,13 +36,13 @@
public class EmptyRepositoryHashSearch
implements RepositoryHashSearch
{
- public List searchBytecodeHash( String hash )
+ public List<Artifact> searchBytecodeHash( String hash )
{
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
- public List searchFileHash( String hash )
+ public List<Artifact> searchFileHash( String hash )
{
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
}
diff --git a/src/main/java/org/apache/maven/shared/jar/identification/repository/RepositoryHashSearch.java b/src/main/java/org/apache/maven/shared/jar/identification/repository/RepositoryHashSearch.java
index cedefab..659c12f 100644
--- a/src/main/java/org/apache/maven/shared/jar/identification/repository/RepositoryHashSearch.java
+++ b/src/main/java/org/apache/maven/shared/jar/identification/repository/RepositoryHashSearch.java
@@ -21,6 +21,8 @@
import java.util.List;
+import org.apache.maven.artifact.Artifact;
+
/**
* Interface for Repository Hash Searches.
*/
@@ -32,7 +34,7 @@
* @param hash the hash code to use
* @return a list of {@link org.apache.maven.artifact.Artifact} instances that matched
*/
- List searchFileHash( String hash );
+ List<Artifact> searchFileHash( String hash );
/**
* Search the repository for artifacts matching the given hash code when consider the bytecode of the classes in the
@@ -41,5 +43,5 @@
* @param hash the hash code to use
* @return a list of {@link org.apache.maven.artifact.Artifact} instances that matched
*/
- List searchBytecodeHash( String hash );
+ List<Artifact> searchBytecodeHash( String hash );
}
diff --git a/src/test/java/org/apache/maven/shared/jar/AbstractJarAnalyzerTestCase.java b/src/test/java/org/apache/maven/shared/jar/AbstractJarAnalyzerTestCase.java
index 80afb2d..780ecc4 100644
--- a/src/test/java/org/apache/maven/shared/jar/AbstractJarAnalyzerTestCase.java
+++ b/src/test/java/org/apache/maven/shared/jar/AbstractJarAnalyzerTestCase.java
@@ -28,7 +28,6 @@
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -47,14 +46,12 @@
return new File( URLDecoder.decode( path, "UTF-8" ) );
}
- public void assertNotContainsRegex( String msg, String regex, Collection coll )
+ public void assertNotContainsRegex( String msg, String regex, Collection<String> coll )
{
- List failures = new ArrayList();
+ List<String> failures = new ArrayList<String>();
Pattern pat = Pattern.compile( regex );
- Iterator it = coll.iterator();
- while ( it.hasNext() )
+ for ( String value : coll )
{
- String value = (String) it.next();
Matcher mat = pat.matcher( value );
if ( mat.find() )
{
@@ -66,10 +63,9 @@
{
StringBuffer sb = new StringBuffer();
sb.append( msg ).append( " collection has illegal regex \"" ).append( regex ).append( "\"" );
- it = failures.iterator();
- while ( it.hasNext() )
+ for ( String failure : failures )
{
- sb.append( "\n - \"" ).append( it.next() ).append( "\"" );
+ sb.append( "\n - \"" ).append( failure ).append( "\"" );
}
throw new AssertionFailedError( sb.toString() );
}
diff --git a/src/test/java/org/apache/maven/shared/jar/classes/ImportVisitorTest.java b/src/test/java/org/apache/maven/shared/jar/classes/ImportVisitorTest.java
index 3c14fe0..aa26bef 100644
--- a/src/test/java/org/apache/maven/shared/jar/classes/ImportVisitorTest.java
+++ b/src/test/java/org/apache/maven/shared/jar/classes/ImportVisitorTest.java
@@ -48,7 +48,7 @@
DescendingVisitor descVisitor = new DescendingVisitor( javaClass, importVisitor );
javaClass.accept( descVisitor );
- List imports = importVisitor.getImports();
+ List<String> imports = importVisitor.getImports();
assertNotNull( "Import List", imports );
assertNotContainsRegex( "Import List", "[\\[\\)\\(\\;]", imports );
@@ -69,7 +69,7 @@
DescendingVisitor descVisitor = new DescendingVisitor( javaClass, importVisitor );
javaClass.accept( descVisitor );
- List imports = importVisitor.getImports();
+ List<String> imports = importVisitor.getImports();
assertNotNull( "Import List", imports );
assertNotContainsRegex( "Import List", "[\\[\\)\\(\\;]", imports );