From 2f9da451728052b0fb6cae53fdd3b35ce2f6a66d Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Sun, 23 Jun 2024 18:06:17 -0700 Subject: [PATCH] More code cleanups --- .../rife/bld/extension/DokkaOperation.java | 46 ++++++------ .../rife/bld/extension/dokka/SourceSet.java | 74 ++++++++----------- 2 files changed, 53 insertions(+), 67 deletions(-) diff --git a/src/main/java/rife/bld/extension/DokkaOperation.java b/src/main/java/rife/bld/extension/DokkaOperation.java index a3366d4..e5a6047 100644 --- a/src/main/java/rife/bld/extension/DokkaOperation.java +++ b/src/main/java/rife/bld/extension/DokkaOperation.java @@ -56,7 +56,7 @@ public class DokkaOperation extends AbstractProcessOperation { private final Map pluginsConfiguration_ = new ConcurrentHashMap<>(); private boolean delayTemplateSubstitution_; private boolean failOnWarning_; - private File json; + private File json_; private LoggingLevel loggingLevel_; private String moduleName_; private String moduleVersion_; @@ -77,11 +77,11 @@ public class DokkaOperation extends AbstractProcessOperation { } /** - * Returns the list of JARs contained in a given directory. + * Returns the JARs contained in a given directory. * * @param directory the directory * @param regex the regular expression to match - * @return the list of JARs + * @return the Java Archives */ public static List getJarList(File directory, String regex) { var jars = new ArrayList(); @@ -255,8 +255,8 @@ public class DokkaOperation extends AbstractProcessOperation { } // json - if (json != null) { - args.add(json.getAbsolutePath()); + if (json_ != null) { + args.add(json_.getAbsolutePath()); } if (LOGGER.isLoggable(Level.FINE)) { @@ -338,7 +338,7 @@ public class DokkaOperation extends AbstractProcessOperation { } /** - * Sets the global list of package configurations. + * Sets the global package configurations. *

* Using format: *

    @@ -355,12 +355,12 @@ public class DokkaOperation extends AbstractProcessOperation { * @return this operation instance */ public DokkaOperation globalPackageOptions(String... options) { - Collections.addAll(globalPackageOptions_, options); + globalPackageOptions_.addAll(List.of(options)); return this; } /** - * Retrieves the global list of package configurations. + * Retrieves the global package configurations. * * @return the package configurations */ @@ -369,7 +369,7 @@ public class DokkaOperation extends AbstractProcessOperation { } /** - * Sets the global list of package configurations. + * Sets the global package configurations. *

    * Using format: *

      @@ -382,7 +382,7 @@ public class DokkaOperation extends AbstractProcessOperation { *
    • ...
    • *
    * - * @param options the list of package configurations + * @param options the package configurations * @return this operation instance */ public DokkaOperation globalPackageOptions(Collection options) { @@ -397,7 +397,7 @@ public class DokkaOperation extends AbstractProcessOperation { * @return this operation instance */ public DokkaOperation globalSrcLink(String... links) { - Collections.addAll(globalSrcLinks_, links); + globalSrcLinks_.addAll(List.of(links)); return this; } @@ -432,7 +432,7 @@ public class DokkaOperation extends AbstractProcessOperation { * @return this operation instance */ public DokkaOperation includes(File... files) { - Collections.addAll(includes_, files); + includes_.addAll(List.of(files)); return this; } @@ -447,9 +447,7 @@ public class DokkaOperation extends AbstractProcessOperation { * @return this operation instance */ public DokkaOperation includes(String... files) { - Collections.addAll(includes_, Arrays.stream(files) - .map(File::new) - .toArray(File[]::new)); + includes_.addAll(Arrays.stream(files).map(File::new).toList()); return this; } @@ -469,7 +467,7 @@ public class DokkaOperation extends AbstractProcessOperation { *

    * This can be configured on per-package basis. * - * @param files the list of files + * @param files the markdown files * @return this operation instance */ public DokkaOperation includes(Collection files) { @@ -483,7 +481,7 @@ public class DokkaOperation extends AbstractProcessOperation { * @param configuration the configuration file path */ public DokkaOperation json(File configuration) { - json = configuration; + json_ = configuration; return this; } @@ -648,26 +646,24 @@ public class DokkaOperation extends AbstractProcessOperation { } /** - * Sets the list of jars with Dokka plugins and their dependencies. + * Sets the jars for Dokka plugins and their dependencies. * * @param jars one or more jars * @return this operation instance */ public DokkaOperation pluginsClasspath(File... jars) { - Collections.addAll(pluginsClasspath_, jars); + pluginsClasspath_.addAll(List.of(jars)); return this; } /** - * Sets the list of jars with Dokka plugins and their dependencies. + * Sets the jars for Dokka plugins and their dependencies. * * @param jars one or more jars * @return this operation instance */ public DokkaOperation pluginsClasspath(String... jars) { - Collections.addAll(pluginsClasspath_, Arrays.stream(jars) - .map(File::new) - .toArray(File[]::new)); + pluginsClasspath_.addAll(Arrays.stream(jars).map(File::new).toList()); return this; } @@ -681,9 +677,9 @@ public class DokkaOperation extends AbstractProcessOperation { } /** - * Sets the list of jars with Dokka plugins and their dependencies. + * Sets the jars for Dokka plugins and their dependencies. * - * @param jars the list of jars + * @param jars the jars * @return this operation instance */ public DokkaOperation pluginsClasspath(Collection jars) { diff --git a/src/main/java/rife/bld/extension/dokka/SourceSet.java b/src/main/java/rife/bld/extension/dokka/SourceSet.java index 1bab8cf..a866749 100644 --- a/src/main/java/rife/bld/extension/dokka/SourceSet.java +++ b/src/main/java/rife/bld/extension/dokka/SourceSet.java @@ -243,7 +243,7 @@ public class SourceSet { * @return this operation instance */ public SourceSet classpath(File... files) { - Collections.addAll(classpath_, files); + classpath_.addAll(List.of(files)); return this; } @@ -258,9 +258,7 @@ public class SourceSet { * @return this operation instance */ public SourceSet classpath(String... files) { - Collections.addAll(classpath_, Arrays.stream(files) - .map(File::new) - .toArray(File[]::new)); + classpath_.addAll(Arrays.stream(files).map(File::new).toList()); return this; } @@ -271,7 +269,7 @@ public class SourceSet { *

    * This option accepts both {@code .jar} and {@code .klib} files. * - * @param files the list of files + * @param files the collection of files * @return this operation instance */ public SourceSet classpath(Collection files) { @@ -349,7 +347,7 @@ public class SourceSet { * @return this operation instance */ public SourceSet documentedVisibilities(DocumentedVisibility... visibilities) { - documentedVisibilities_.addAll(Arrays.asList(visibilities)); + documentedVisibilities_.addAll(List.of(visibilities)); return this; } @@ -402,7 +400,7 @@ public class SourceSet { /** * Sets the Markdown files that contain module and package documentation. *

    - * A list of Markdown files that contain module and package documentation. + * The Markdown files that contain module and package documentation. *

    * The contents of the specified files are parsed and embedded into documentation as module and package * descriptions. @@ -411,14 +409,14 @@ public class SourceSet { * @return this operation instance */ public SourceSet includes(File... files) { - Collections.addAll(includes_, files); + includes_.addAll(List.of(files)); return this; } /** * Sets the Markdown files that contain module and package documentation. *

    - * A list of Markdown files that contain module and package documentation. + * The Markdown files that contain module and package documentation. *

    * The contents of the specified files are parsed and embedded into documentation as module and package * descriptions. @@ -427,9 +425,7 @@ public class SourceSet { * @return this operation instance */ public SourceSet includes(String... files) { - Collections.addAll(includes_, Arrays.stream(files) - .map(File::new) - .toArray(File[]::new)); + includes_.addAll(Arrays.stream(files).map(File::new).toList()); return this; } @@ -445,12 +441,12 @@ public class SourceSet { /** * Sets the Markdown files that contain module and package documentation. *

    - * A list of Markdown files that contain module and package documentation. + * The Markdown files that contain module and package documentation. *

    * The contents of the specified files are parsed and embedded into documentation as module and package * descriptions. * - * @param files the list of files + * @param files the collection of files * @return this operation instance */ public SourceSet includes(Collection files) { @@ -559,7 +555,7 @@ public class SourceSet { } /** - * Set the list of package source set configuration. + * Set the package source set configuration. *

    * A set of parameters specific to matched packages within this source set. *

    @@ -574,7 +570,7 @@ public class SourceSet { *

  • ...
  • *
* - * @param perPackageOptions the list of per package options + * @param perPackageOptions the per package options * @return this operation instance */ public SourceSet perPackageOptions(Collection perPackageOptions) { @@ -583,7 +579,7 @@ public class SourceSet { } /** - * Retrieves the list of package source set configuration. + * Retrieves the package source set configuration. * * @return the package source set configuration */ @@ -592,7 +588,7 @@ public class SourceSet { } /** - * Set the list of package source set configuration. + * Set the package source set configuration. *

* A set of parameters specific to matched packages within this source set. *

@@ -607,11 +603,11 @@ public class SourceSet { *

  • ...
  • * * - * @param perPackageOptions the list of per package options + * @param perPackageOptions the per package options * @return this operation instance */ public SourceSet perPackageOptions(String... perPackageOptions) { - Collections.addAll(perPackageOptions_, perPackageOptions); + perPackageOptions_.addAll(List.of(perPackageOptions)); return this; } @@ -634,12 +630,12 @@ public class SourceSet { } /** - * Set the list of directories or files that contain sample functions. + * Set the directories or files that contain sample functions. *

    - * A list of directories or files that contain sample functions which are referenced via the {@code @sample} KDoc + * The directories or files that contain sample functions which are referenced via the {@code @sample} KDoc * tag. * - * @param samples the list of samples + * @param samples the samples * @return this operation instance */ public SourceSet samples(Collection samples) { @@ -648,7 +644,7 @@ public class SourceSet { } /** - * Retrieves the list of directories or files that contain sample functions. + * Retrieves the directories or files that contain sample functions. * * @return the directories or files */ @@ -657,32 +653,30 @@ public class SourceSet { } /** - * Set the list of directories or files that contain sample functions. + * Set the directories or files that contain sample functions. *

    - * A list of directories or files that contain sample functions which are referenced via the {@code @sample} KDoc + * The directories or files that contain sample functions which are referenced via the {@code @sample} KDoc * tag. * * @param samples nne or more samples * @return this operation instance */ public SourceSet samples(File... samples) { - Collections.addAll(samples_, samples); + samples_.addAll(List.of(samples)); return this; } /** - * Set the list of directories or files that contain sample functions. + * Set the directories or files that contain sample functions. *

    - * A list of directories or files that contain sample functions which are referenced via the {@code @sample} KDoc + * The directories or files that contain sample functions which are referenced via the {@code @sample} KDoc * tag. * * @param samples nne or more samples * @return this operation instance */ public SourceSet samples(String... samples) { - Collections.addAll(samples_, Arrays.stream(samples) - .map(File::new) - .toArray(File[]::new)); + samples_.addAll(Arrays.stream(samples).map(File::new).toList()); return this; } @@ -718,7 +712,7 @@ public class SourceSet { * The source code roots to be analyzed and documented. Acceptable inputs are directories and individual * {@code .kt} / {@code .java} files. * - * @param src the list of source code roots + * @param src the source code roots * @return this operation instance */ public SourceSet src(Collection src) { @@ -736,7 +730,7 @@ public class SourceSet { * @return this operation instance */ public SourceSet src(File... src) { - Collections.addAll(src_, src); + src_.addAll(List.of(src)); return this; } @@ -750,9 +744,7 @@ public class SourceSet { * @return this operation instance */ public SourceSet src(String... src) { - Collections.addAll(src_, Arrays.stream(src) - .map(File::new) - .toArray(File[]::new)); + src_.addAll(Arrays.stream(src).map(File::new).toList()); return this; } @@ -805,7 +797,7 @@ public class SourceSet { *

    * The files to be suppressed when generating documentation. * - * @param suppressedFiles the list of suppressed files + * @param suppressedFiles the suppressed files * @return this operation instance */ public SourceSet suppressedFiles(Collection suppressedFiles) { @@ -832,9 +824,7 @@ public class SourceSet { * @return this operation instance */ public SourceSet suppressedFiles(String... suppressedFiles) { - Collections.addAll(suppressedFiles_, Arrays.stream(suppressedFiles) - .map(File::new) - .toArray(File[]::new)); + suppressedFiles_.addAll(Arrays.stream(suppressedFiles).map(File::new).toList()); return this; } @@ -847,7 +837,7 @@ public class SourceSet { * @return this operation instance */ public SourceSet suppressedFiles(File... suppressedFiles) { - suppressedFiles_.addAll(Arrays.asList(suppressedFiles)); + suppressedFiles_.addAll(List.of(suppressedFiles)); return this; } }