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

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