r***@apache.org
2018-12-09 14:45:43 UTC
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MJAVADOC-548
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git
commit 58ff79cbfddf077fa169b04c0564f488700a522a
Author: rfscholte <***@apache.org>
AuthorDate: Sat Dec 8 20:52:27 2018 +0100
Remove index based loops
---
.../apache/maven/plugins/javadoc/JavadocUtil.java | 23 +++++++++-------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
index 23fd546..d6a8ae6 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
@@ -200,8 +200,7 @@ public class JavadocUtil
List<String> excludedNames = new ArrayList<>();
for ( String path : sourcePaths )
{
- List<String> excludes = getExcludedPackages( path, excludedPackages );
- excludedNames.addAll( excludes );
+ excludedNames.addAll( getExcludedPackages( path, excludedPackages ) );
}
return excludedNames;
@@ -380,29 +379,28 @@ public class JavadocUtil
* @param excludePackagenames package names to be excluded in the javadoc
* @return a List of the packagenames to be excluded
*/
- protected static List<String> getExcludedPackages( String sourceDirectory, String[] excludePackagenames )
+ protected static Collection<String> getExcludedPackages( String sourceDirectory, String[] excludePackagenames )
{
List<String> files = new ArrayList<>();
for ( String excludePackagename : excludePackagenames )
{
+ String[] excludeName = excludePackagename.split( "[*]" );
+
String[] fileList = FileUtils.getFilesFromExtension( sourceDirectory, new String[] { "java" } );
for ( String aFileList : fileList )
{
- String[] excludeName = excludePackagename.split( "[*]" );
- int u = 0;
- while ( u < excludeName.length )
+ for ( String excludePart : excludeName )
{
- if ( !"".equals( excludeName[u].trim() ) && aFileList.contains( excludeName[u] )
- && !sourceDirectory.contains( excludeName[u] ) )
+ if ( !"".equals( excludePart.trim() ) && aFileList.contains( excludePart )
+ && !sourceDirectory.contains( excludePart ) )
{
files.add( aFileList );
}
- u++;
}
}
}
- List<String> excluded = new ArrayList<>();
+ Set<String> excluded = new LinkedHashSet<>();
for ( String file : files )
{
int idx = file.lastIndexOf( File.separatorChar );
@@ -411,10 +409,7 @@ public class JavadocUtil
String[] srcSplit = tmpStr.split( Pattern.quote( sourceDirectory.replace( '\\', '/' ) + '/' ) );
String excludedPackage = srcSplit[1].replace( '/', '.' );
- if ( !excluded.contains( excludedPackage ) )
- {
- excluded.add( excludedPackage );
- }
+ excluded.add( excludedPackage );
}
return excluded;
rfscholte pushed a commit to branch MJAVADOC-548
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git
commit 58ff79cbfddf077fa169b04c0564f488700a522a
Author: rfscholte <***@apache.org>
AuthorDate: Sat Dec 8 20:52:27 2018 +0100
Remove index based loops
---
.../apache/maven/plugins/javadoc/JavadocUtil.java | 23 +++++++++-------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
index 23fd546..d6a8ae6 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/JavadocUtil.java
@@ -200,8 +200,7 @@ public class JavadocUtil
List<String> excludedNames = new ArrayList<>();
for ( String path : sourcePaths )
{
- List<String> excludes = getExcludedPackages( path, excludedPackages );
- excludedNames.addAll( excludes );
+ excludedNames.addAll( getExcludedPackages( path, excludedPackages ) );
}
return excludedNames;
@@ -380,29 +379,28 @@ public class JavadocUtil
* @param excludePackagenames package names to be excluded in the javadoc
* @return a List of the packagenames to be excluded
*/
- protected static List<String> getExcludedPackages( String sourceDirectory, String[] excludePackagenames )
+ protected static Collection<String> getExcludedPackages( String sourceDirectory, String[] excludePackagenames )
{
List<String> files = new ArrayList<>();
for ( String excludePackagename : excludePackagenames )
{
+ String[] excludeName = excludePackagename.split( "[*]" );
+
String[] fileList = FileUtils.getFilesFromExtension( sourceDirectory, new String[] { "java" } );
for ( String aFileList : fileList )
{
- String[] excludeName = excludePackagename.split( "[*]" );
- int u = 0;
- while ( u < excludeName.length )
+ for ( String excludePart : excludeName )
{
- if ( !"".equals( excludeName[u].trim() ) && aFileList.contains( excludeName[u] )
- && !sourceDirectory.contains( excludeName[u] ) )
+ if ( !"".equals( excludePart.trim() ) && aFileList.contains( excludePart )
+ && !sourceDirectory.contains( excludePart ) )
{
files.add( aFileList );
}
- u++;
}
}
}
- List<String> excluded = new ArrayList<>();
+ Set<String> excluded = new LinkedHashSet<>();
for ( String file : files )
{
int idx = file.lastIndexOf( File.separatorChar );
@@ -411,10 +409,7 @@ public class JavadocUtil
String[] srcSplit = tmpStr.split( Pattern.quote( sourceDirectory.replace( '\\', '/' ) + '/' ) );
String excludedPackage = srcSplit[1].replace( '/', '.' );
- if ( !excluded.contains( excludedPackage ) )
- {
- excluded.add( excludedPackage );
- }
+ excluded.add( excludedPackage );
}
return excluded;