Merge pull request #17 from rhowe/tidyups

Miscellaneous code cleanups
diff --git a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
index 93394d8..ea172ab 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
@@ -1667,7 +1667,7 @@
 
             resolutionErrorHandler.throwErrors( request, resolutionResult );
 
-            List<String> elements = new ArrayList<String>( resolutionResult.getArtifacts().size() );
+            List<String> elements = new ArrayList<>( resolutionResult.getArtifacts().size() );
 
             for ( Object resolved : resolutionResult.getArtifacts() )
             {
diff --git a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
index 8bc437b..78d3908 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
@@ -230,7 +230,7 @@
                                        .setMainModuleDescriptor( moduleDescriptorPath );
                 
                 Toolchain toolchain = getToolchain();
-                if ( toolchain != null && toolchain instanceof DefaultJavaToolChain )
+                if ( toolchain instanceof DefaultJavaToolChain )
                 {
                     request.setJdkHome( new File( ( (DefaultJavaToolChain) toolchain ).getJavaHome() ) );
                 }
@@ -256,27 +256,22 @@
                 {
                     pathElements.put( entry.getKey().getPath(), entry.getValue() );
                 }
-                
+
+                if ( compilerArgs == null )
+                {
+                    compilerArgs = new ArrayList<>();
+                }
+
                 for ( File file : resolvePathsResult.getClasspathElements() )
                 {
                     classpathElements.add( file.getPath() );
                     
                     if ( multiReleaseOutput )
                     {
-                        if ( compilerArgs == null )
-                        {
-                            compilerArgs = new ArrayList<>();
-                        }
-                        
                         if ( getOutputDirectory().toPath().startsWith( file.getPath() ) )
                         {
                             compilerArgs.add( "--patch-module" );
-                            
-                            StringBuilder patchModuleValue = new StringBuilder( moduleDescriptor.name() )
-                                            .append( '=' )
-                                            .append( file.getPath() );
-                            
-                            compilerArgs.add( patchModuleValue.toString() );
+                            compilerArgs.add( String.format( "%s=%s", moduleDescriptor.name(), file.getPath() ) );
                         }
                     }
                 }
@@ -286,10 +281,6 @@
                     modulepathElements.add( file.getPath() );
                 }
                 
-                if ( compilerArgs == null )
-                {
-                    compilerArgs = new ArrayList<>();
-                }
                 compilerArgs.add( "--module-version" );
                 compilerArgs.add( getProject().getVersion() );
                 
diff --git a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
index f8b9ba1..5b0518b 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
@@ -241,7 +241,7 @@
                                 .setMainModuleDescriptor( mainModuleDescriptorClassFile.getAbsolutePath() );
 
                 Toolchain toolchain = getToolchain();
-                if ( toolchain != null && toolchain instanceof DefaultJavaToolChain )
+                if ( toolchain instanceof DefaultJavaToolChain )
                 {
                     request.setJdkHome( ( (DefaultJavaToolChain) toolchain ).getJavaHome() );
                 }
@@ -285,7 +285,7 @@
                                 .setMainModuleDescriptor( testModuleDescriptorJavaFile.getAbsolutePath() );
 
                 Toolchain toolchain = getToolchain();
-                if ( toolchain != null && toolchain instanceof DefaultJavaToolChain )
+                if ( toolchain instanceof DefaultJavaToolChain )
                 {
                     request.setJdkHome( ( (DefaultJavaToolChain) toolchain ).getJavaHome() );
                 }
@@ -336,7 +336,7 @@
                 {
                     if ( compilerArgs == null )
                     {
-                        compilerArgs = new ArrayList<String>();
+                        compilerArgs = new ArrayList<>();
                     }
                     compilerArgs.add( "--patch-module" );
 
@@ -380,7 +380,7 @@
             {
                 if ( compilerArgs == null )
                 {
-                    compilerArgs = new ArrayList<String>();
+                    compilerArgs = new ArrayList<>();
                 }
                 compilerArgs.add( "--patch-module" );
                 
diff --git a/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java b/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java
index 37a60ca..348cfb0 100644
--- a/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java
+++ b/src/test/java/org/apache/maven/plugin/compiler/CompilerMojoTestCase.java
@@ -161,11 +161,11 @@
         CompilerMojo compileMojo =
             getCompilerMojo( "target/test-classes/unit/compiler-includes-excludes-test/plugin-config.xml" );
 
-        Set<String> includes = new HashSet<String>();
+        Set<String> includes = new HashSet<>();
         includes.add( "**/TestCompile4*.java" );
         setVariableValueToObject( compileMojo, "includes", includes );
 
-        Set<String> excludes = new HashSet<String>();
+        Set<String> excludes = new HashSet<>();
         excludes.add( "**/TestCompile2*.java" );
         excludes.add( "**/TestCompile3*.java" );
         setVariableValueToObject( compileMojo, "excludes", excludes );
@@ -275,11 +275,11 @@
 
         setVariableValueToObject( compileMojo, "compilerManager", new CompilerManagerStub() );
 
-        Set<String> includes = new HashSet<String>();
+        Set<String> includes = new HashSet<>();
         includes.add( "**/TestCompile4*.java" );
         setVariableValueToObject( compileMojo, "includes", includes );
 
-        Set<String> excludes = new HashSet<String>();
+        Set<String> excludes = new HashSet<>();
         excludes.add( "**/TestCompile2*.java" );
         excludes.add( "**/TestCompile3*.java" );
         setVariableValueToObject( compileMojo, "excludes", excludes );
@@ -414,7 +414,7 @@
         File testClassesDir = new File( buildDir, "test-classes" );
         setVariableValueToObject( mojo, "outputDirectory", testClassesDir );
 
-        List<String> testClasspathList = new ArrayList<String>();
+        List<String> testClasspathList = new ArrayList<>();
         
         Artifact junitArtifact = mock( Artifact.class );
         ArtifactHandler handler = mock( ArtifactHandler.class );
diff --git a/src/test/java/org/apache/maven/plugin/compiler/stubs/CompilerManagerStub.java b/src/test/java/org/apache/maven/plugin/compiler/stubs/CompilerManagerStub.java
index efa5ee9..eff1ce3 100644
--- a/src/test/java/org/apache/maven/plugin/compiler/stubs/CompilerManagerStub.java
+++ b/src/test/java/org/apache/maven/plugin/compiler/stubs/CompilerManagerStub.java
@@ -20,7 +20,6 @@
  */
 
 import org.codehaus.plexus.compiler.manager.CompilerManager;
-import org.codehaus.plexus.compiler.manager.NoSuchCompilerException;
 
 /**
  * @author Edwin Punzalan
@@ -41,7 +40,6 @@
     }
 
     public org.codehaus.plexus.compiler.Compiler getCompiler( String compilerId )
-        throws NoSuchCompilerException
     {
         return new CompilerStub( shouldFail );
     }
diff --git a/src/test/java/org/apache/maven/plugin/compiler/stubs/CompilerStub.java b/src/test/java/org/apache/maven/plugin/compiler/stubs/CompilerStub.java
index 94710c6..fd94cc2 100644
--- a/src/test/java/org/apache/maven/plugin/compiler/stubs/CompilerStub.java
+++ b/src/test/java/org/apache/maven/plugin/compiler/stubs/CompilerStub.java
@@ -55,25 +55,21 @@
     }
 
     public String getInputFileEnding( CompilerConfiguration compilerConfiguration )
-        throws CompilerException
     {
         return "java";
     }
 
     public String getOutputFileEnding( CompilerConfiguration compilerConfiguration )
-        throws CompilerException
     {
         return "class";
     }
 
     public String getOutputFile( CompilerConfiguration compilerConfiguration )
-        throws CompilerException
     {
         return "output-file";
     }
 
     public boolean canUpdateTarget( CompilerConfiguration compilerConfiguration )
-        throws CompilerException
     {
         return false;
     }
@@ -126,7 +122,6 @@
     }
 
     public String[] createCommandLine( CompilerConfiguration compilerConfiguration )
-        throws CompilerException
     {
         return new String[0];
     }