Adding null checks for lists of artifacts before mapping them...now methods will simply return empty Map instances if null lists are passed in.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@225321 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-07-26 15:00:36 +00:00
parent 17991ceea7
commit 89371bb7fd
1 changed files with 13 additions and 7 deletions

View File

@ -53,12 +53,15 @@ public final class ArtifactUtils
public static Map artifactMapByVersionlessId( Collection artifacts )
{
Map artifactMap = new HashMap();
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
if ( artifacts != null )
{
Artifact artifact = (Artifact) it.next();
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
{
Artifact artifact = (Artifact) it.next();
artifactMap.put( versionlessKey( artifact ), artifact );
artifactMap.put( versionlessKey( artifact ), artifact );
}
}
return artifactMap;
@ -68,11 +71,14 @@ public final class ArtifactUtils
{
Map artifactMap = new HashMap();
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
if ( artifacts != null )
{
Artifact artifact = (Artifact) it.next();
for ( Iterator it = artifacts.iterator(); it.hasNext(); )
{
Artifact artifact = (Artifact) it.next();
artifactMap.put( artifact.getId(), artifact );
artifactMap.put( artifact.getId(), artifact );
}
}
return artifactMap;