From f516f754c5ad9235cf73635c3c19ea9d216c5479 Mon Sep 17 00:00:00 2001 From: Herve Boutemy Date: Sun, 9 Nov 2014 21:26:03 +0000 Subject: [PATCH] code simplification git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1637747 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/plugin/plugin/PluginReport.java | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java index 09af885..65042e9 100644 --- a/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java +++ b/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginReport.java @@ -671,7 +671,7 @@ public class PluginReport } if ( jdk == null && project.getPluginManagement() != null ) { - jdk = discoverJdkRequirementFromPlugins( project.getPluginManagement().getPluginsAsMap() ); + jdk = discoverJdkRequirementFromPlugins( project.getPluginManagement().getPluginsAsMap() ); } if ( jdk == null ) { @@ -685,8 +685,7 @@ public class PluginReport * @param pluginsAsMap could be null * @return the value of the target in the configuration of maven-compiler-plugin. */ - @SuppressWarnings( "rawtypes" ) - private static String discoverJdkRequirementFromPlugins( Map pluginsAsMap ) + private static String discoverJdkRequirementFromPlugins( Map pluginsAsMap ) { if ( pluginsAsMap == null ) { @@ -695,16 +694,14 @@ public class PluginReport String jdk = null; String backupJdk = null; - for ( Iterator it = pluginsAsMap.keySet().iterator(); it.hasNext(); ) + for ( Map.Entry entry : pluginsAsMap.entrySet() ) { - String key = it.next().toString(); - - if ( !key.equals( "org.apache.maven.plugins:maven-compiler-plugin" ) ) + if ( !entry.getKey().equals( "org.apache.maven.plugins:maven-compiler-plugin" ) ) { continue; } - Object value = pluginsAsMap.get( key ); + Object value = entry.getValue(); Xpp3Dom pluginConf = null; backupJdk = "Default version for maven-compiler-plugin"; @@ -727,22 +724,14 @@ public class PluginReport continue; } - if ( pluginConf.getChild( "target" ) == null ) + Xpp3Dom target = pluginConf.getChild( "target" ); + if ( target != null ) { - continue; + jdk = target.getValue(); } - - jdk = pluginConf.getChild( "target" ).getValue(); } - if ( jdk == null ) - { - return backupJdk; - } - else - { - return jdk; - } + return ( jdk == null ) ? backupJdk : jdk; } } }