More java7. Bye bye 2006

This commit is contained in:
Kristian Rosenvold 2015-06-20 15:21:10 +02:00
parent 7f206ef1cc
commit cfd1fbe613
13 changed files with 44 additions and 71 deletions

View File

@ -75,11 +75,11 @@ public class GroupRepositoryMetadata
String artifactId,
String name )
{
List plugins = getMetadata().getPlugins();
List<Plugin> plugins = getMetadata().getPlugins();
boolean found = false;
for ( Iterator i = plugins.iterator(); i.hasNext() && !found; )
for ( Iterator<Plugin> i = plugins.iterator(); i.hasNext() && !found; )
{
Plugin plugin = (Plugin) i.next();
Plugin plugin = i.next();
if ( plugin.getPrefix().equals( goalPrefix ) )
{
found = true;

View File

@ -93,7 +93,7 @@ public class DefaultProfileManager
return requestProperties;
}
public Map getProfilesById()
public Map<String, Profile> getProfilesById()
{
return profilesById;
}
@ -138,13 +138,11 @@ public class DefaultProfileManager
/* (non-Javadoc)
* @see org.apache.maven.profiles.ProfileManager#explicitlyActivate(java.util.List)
*/
public void explicitlyActivate( List profileIds )
public void explicitlyActivate( List<String> profileIds )
{
for ( Object profileId1 : profileIds )
for ( String profileId1 : profileIds )
{
String profileId = (String) profileId1;
explicitlyActivate( profileId );
explicitlyActivate( profileId1 );
}
}
@ -164,13 +162,11 @@ public class DefaultProfileManager
/* (non-Javadoc)
* @see org.apache.maven.profiles.ProfileManager#explicitlyDeactivate(java.util.List)
*/
public void explicitlyDeactivate( List profileIds )
public void explicitlyDeactivate( List<String> profileIds )
{
for ( Object profileId1 : profileIds )
for ( String profileId1 : profileIds )
{
String profileId = (String) profileId1;
explicitlyDeactivate( profileId );
explicitlyDeactivate( profileId1 );
}
}
@ -212,13 +208,11 @@ public class DefaultProfileManager
/* (non-Javadoc)
* @see org.apache.maven.profiles.ProfileManager#addProfiles(java.util.List)
*/
public void addProfiles( List profiles )
public void addProfiles( List<Profile> profiles )
{
for ( Object profile1 : profiles )
for ( Profile profile1 : profiles )
{
Profile profile = (Profile) profile1;
addProfile( profile );
addProfile( profile1 );
}
}

View File

@ -34,16 +34,16 @@ public interface ProfileManager
void explicitlyActivate( String profileId );
void explicitlyActivate( List profileIds );
void explicitlyActivate( List<String> profileIds );
void explicitlyDeactivate( String profileId );
void explicitlyDeactivate( List profileIds );
void explicitlyDeactivate( List<String> profileIds );
List getActiveProfiles()
throws ProfileActivationException;
void addProfiles( List profiles );
void addProfiles( List<Profile> profiles );
Map getProfilesById();

View File

@ -342,9 +342,9 @@ public class DefaultLegacyArtifactCollector
// Conflict Resolution
ResolutionNode resolved = null;
for ( Iterator j = conflictResolvers.iterator(); ( resolved == null ) && j.hasNext(); )
for ( Iterator<ConflictResolver> j = conflictResolvers.iterator(); ( resolved == null ) && j.hasNext(); )
{
ConflictResolver conflictResolver = (ConflictResolver) j.next();
ConflictResolver conflictResolver = j.next();
resolved = conflictResolver.resolveConflict( previous, node );
}
@ -424,9 +424,9 @@ public class DefaultLegacyArtifactCollector
Artifact parentArtifact = node.getArtifact();
for ( Iterator i = node.getChildrenIterator(); i.hasNext(); )
for ( Iterator<ResolutionNode> i = node.getChildrenIterator(); i.hasNext(); )
{
ResolutionNode child = (ResolutionNode) i.next();
ResolutionNode child = i.next();
try
{

View File

@ -78,5 +78,5 @@ public interface ArtifactTransformationManager
ArtifactRepository localRepository )
throws ArtifactDeploymentException;
List getArtifactTransformations();
List<ArtifactTransformation> getArtifactTransformations();
}

View File

@ -79,7 +79,7 @@ public class DefaultArtifactTransformationManager
}
}
public List getArtifactTransformations()
public List<ArtifactTransformation> getArtifactTransformations()
{
return artifactTransformations;
}

View File

@ -44,7 +44,7 @@ public class ExpressionDocumenter
private static Map<String, Expression> expressionDocumentation;
public static Map load()
public static Map<String, Expression> load()
throws ExpressionDocumentationException
{
if ( expressionDocumentation == null )
@ -117,17 +117,15 @@ public class ExpressionDocumenter
ExpressionDocumentation documentation = paramdocReader.read( reader, true );
List expressions = documentation.getExpressions();
List<Expression> expressions = documentation.getExpressions();
Map<String, Expression> bySyntax = new HashMap<>();
if ( expressions != null && !expressions.isEmpty() )
{
for ( Object expression : expressions )
for ( Expression expression : expressions )
{
Expression expr = (Expression) expression;
bySyntax.put( expr.getSyntax(), expr );
bySyntax.put( expression.getSyntax(), expression );
}
}

View File

@ -241,7 +241,7 @@ public class ArtifactResolverTest
printErrors( result );
Iterator i = result.getArtifacts().iterator();
Iterator<Artifact> i = result.getArtifacts().iterator();
assertEquals( "n should be first", n, i.next() );
assertEquals( "m should be second", m, i.next() );

View File

@ -50,7 +50,7 @@ public class LifecyclePhase
public void set( String goals )
{
mojos = new ArrayList<LifecycleMojo>();
mojos = new ArrayList<>();
String[] mojoGoals = StringUtils.split( goals, "," );

View File

@ -60,7 +60,7 @@ public interface PluginManager
Object getPluginComponent( Plugin plugin, String role, String roleHint )
throws PluginManagerException, ComponentLookupException;
Map getPluginComponents( Plugin plugin, String role )
Map<String, Object> getPluginComponents( Plugin plugin, String role )
throws ComponentLookupException, PluginManagerException;
/**

View File

@ -203,8 +203,7 @@ public class DefaultMavenPluginManager
{
if ( pluginFile.isFile() )
{
JarFile pluginJar = new JarFile( pluginFile, false );
try
try ( JarFile pluginJar = new JarFile( pluginFile, false ) )
{
ZipEntry pluginDescriptorEntry = pluginJar.getEntry( getPluginDescriptorLocation() );
@ -215,10 +214,6 @@ public class DefaultMavenPluginManager
pluginDescriptor = parsePluginDescriptor( is, plugin, pluginFile.getAbsolutePath() );
}
}
finally
{
pluginJar.close();
}
}
else
{
@ -274,11 +269,7 @@ public class DefaultMavenPluginManager
return pluginDescriptor;
}
catch ( IOException e )
{
throw new PluginDescriptorParsingException( plugin, descriptorLocation, e );
}
catch ( PlexusConfigurationException e )
catch ( IOException | PlexusConfigurationException e )
{
throw new PluginDescriptorParsingException( plugin, descriptorLocation, e );
}
@ -369,7 +360,7 @@ public class DefaultMavenPluginManager
if ( cacheRecord != null )
{
pluginDescriptor.setClassRealm( cacheRecord.realm );
pluginDescriptor.setArtifacts( new ArrayList<Artifact>( cacheRecord.artifacts ) );
pluginDescriptor.setArtifacts( new ArrayList<>( cacheRecord.artifacts ) );
for ( ComponentDescriptor<?> componentDescriptor : pluginDescriptor.getComponents() )
{
componentDescriptor.setRealm( cacheRecord.realm );
@ -450,13 +441,7 @@ public class DefaultMavenPluginManager
( (DefaultPlexusContainer) container ).discoverComponents( pluginRealm, new SessionScopeModule( container ),
new MojoExecutionScopeModule( container ) );
}
catch ( ComponentLookupException e )
{
throw new PluginContainerException( plugin, pluginRealm,
"Error in component graph of plugin " + plugin.getId() + ": "
+ e.getMessage(), e );
}
catch ( CycleDetectedInComponentGraphException e )
catch ( ComponentLookupException | CycleDetectedInComponentGraphException e )
{
throw new PluginContainerException( plugin, pluginRealm,
"Error in component graph of plugin " + plugin.getId() + ": "
@ -466,12 +451,12 @@ public class DefaultMavenPluginManager
private List<org.eclipse.aether.artifact.Artifact> toAetherArtifacts( final List<Artifact> pluginArtifacts )
{
return new ArrayList<org.eclipse.aether.artifact.Artifact>( RepositoryUtils.toArtifacts( pluginArtifacts ) );
return new ArrayList<>( RepositoryUtils.toArtifacts( pluginArtifacts ) );
}
private List<Artifact> toMavenArtifacts( DependencyNode root, PreorderNodeListGenerator nlg )
{
List<Artifact> artifacts = new ArrayList<Artifact>( nlg.getNodes().size() );
List<Artifact> artifacts = new ArrayList<>( nlg.getNodes().size() );
RepositoryUtils.toArtifacts( artifacts, Collections.singleton( root ), Collections.<String>emptyList(), null );
for ( Iterator<Artifact> it = artifacts.iterator(); it.hasNext(); )
{
@ -486,7 +471,7 @@ public class DefaultMavenPluginManager
private Map<String, ClassLoader> calcImports( MavenProject project, ClassLoader parent, List<String> imports )
{
Map<String, ClassLoader> foreignImports = new HashMap<String, ClassLoader>();
Map<String, ClassLoader> foreignImports = new HashMap<>();
ClassLoader projectRealm = project.getClassRealm();
if ( projectRealm != null )
@ -661,7 +646,7 @@ public class DefaultMavenPluginManager
{
if ( "basic".equals( configuratorId ) )
{
throw new PluginParameterException( mojoDescriptor, new ArrayList<Parameter>( missingParameters ) );
throw new PluginParameterException( mojoDescriptor, new ArrayList<>( missingParameters ) );
}
else
{
@ -736,7 +721,7 @@ public class DefaultMavenPluginManager
return;
}
List<Parameter> invalidParameters = new ArrayList<Parameter>();
List<Parameter> invalidParameters = new ArrayList<>();
for ( Parameter parameter : mojoDescriptor.getParameters() )
{
@ -811,7 +796,7 @@ public class DefaultMavenPluginManager
(Map<String, ExtensionRealmCache.CacheRecord>) project.getContextValue( KEY_EXTENSIONS_REALMS );
if ( pluginRealms == null )
{
pluginRealms = new HashMap<String, ExtensionRealmCache.CacheRecord>();
pluginRealms = new HashMap<>();
project.setContextValue( KEY_EXTENSIONS_REALMS, pluginRealms );
}
@ -890,11 +875,7 @@ public class DefaultMavenPluginManager
{
pluginDescriptor = extractPluginDescriptor( artifacts.get( 0 ), plugin );
}
catch ( PluginDescriptorParsingException e )
{
// ignore, see above
}
catch ( InvalidPluginDescriptorException e )
catch ( PluginDescriptorParsingException | InvalidPluginDescriptorException e )
{
// ignore, see above
}

View File

@ -19,8 +19,6 @@ package org.apache.maven.plugin.internal;
* under the License.
*/
import java.util.Map;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
@ -59,6 +57,8 @@ import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import java.util.Map;
/**
* @author Benjamin Bentmann
*/
@ -121,7 +121,7 @@ public class DefaultPluginManager
}
}
public Map getPluginComponents( Plugin plugin, String role )
public Map<String, Object> getPluginComponents( Plugin plugin, String role )
throws ComponentLookupException, PluginManagerException
{
MavenSession session = legacySupport.getSession();

View File

@ -147,7 +147,7 @@ public class DefaultSettingsValidator
if ( proxies != null )
{
Set<String> proxyIds = new HashSet<String>();
Set<String> proxyIds = new HashSet<>();
for ( Proxy proxy : proxies )
{