More code cleanups

This commit is contained in:
Erik C. Thauvin 2024-06-23 18:06:17 -07:00
parent 75a864acfe
commit 2f9da45172
Signed by: erik
GPG key ID: 776702A6A2DA330E
2 changed files with 53 additions and 67 deletions

View file

@ -56,7 +56,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
private final Map<String, String> pluginsConfiguration_ = new ConcurrentHashMap<>(); private final Map<String, String> pluginsConfiguration_ = new ConcurrentHashMap<>();
private boolean delayTemplateSubstitution_; private boolean delayTemplateSubstitution_;
private boolean failOnWarning_; private boolean failOnWarning_;
private File json; private File json_;
private LoggingLevel loggingLevel_; private LoggingLevel loggingLevel_;
private String moduleName_; private String moduleName_;
private String moduleVersion_; private String moduleVersion_;
@ -77,11 +77,11 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
} }
/** /**
* Returns the list of JARs contained in a given directory. * Returns the JARs contained in a given directory.
* *
* @param directory the directory * @param directory the directory
* @param regex the regular expression to match * @param regex the regular expression to match
* @return the list of JARs * @return the Java Archives
*/ */
public static List<File> getJarList(File directory, String regex) { public static List<File> getJarList(File directory, String regex) {
var jars = new ArrayList<File>(); var jars = new ArrayList<File>();
@ -255,8 +255,8 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
} }
// json // json
if (json != null) { if (json_ != null) {
args.add(json.getAbsolutePath()); args.add(json_.getAbsolutePath());
} }
if (LOGGER.isLoggable(Level.FINE)) { if (LOGGER.isLoggable(Level.FINE)) {
@ -338,7 +338,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
} }
/** /**
* Sets the global list of package configurations. * Sets the global package configurations.
* <p> * <p>
* Using format: * Using format:
* <ul> * <ul>
@ -355,12 +355,12 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation globalPackageOptions(String... options) { public DokkaOperation globalPackageOptions(String... options) {
Collections.addAll(globalPackageOptions_, options); globalPackageOptions_.addAll(List.of(options));
return this; return this;
} }
/** /**
* Retrieves the global list of package configurations. * Retrieves the global package configurations.
* *
* @return the package configurations * @return the package configurations
*/ */
@ -369,7 +369,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
} }
/** /**
* Sets the global list of package configurations. * Sets the global package configurations.
* <p> * <p>
* Using format: * Using format:
* <ul> * <ul>
@ -382,7 +382,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* <li>...</li> * <li>...</li>
* </ul> * </ul>
* *
* @param options the list of package configurations * @param options the package configurations
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation globalPackageOptions(Collection<String> options) { public DokkaOperation globalPackageOptions(Collection<String> options) {
@ -397,7 +397,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation globalSrcLink(String... links) { public DokkaOperation globalSrcLink(String... links) {
Collections.addAll(globalSrcLinks_, links); globalSrcLinks_.addAll(List.of(links));
return this; return this;
} }
@ -432,7 +432,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation includes(File... files) { public DokkaOperation includes(File... files) {
Collections.addAll(includes_, files); includes_.addAll(List.of(files));
return this; return this;
} }
@ -447,9 +447,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation includes(String... files) { public DokkaOperation includes(String... files) {
Collections.addAll(includes_, Arrays.stream(files) includes_.addAll(Arrays.stream(files).map(File::new).toList());
.map(File::new)
.toArray(File[]::new));
return this; return this;
} }
@ -469,7 +467,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* <p> * <p>
* This can be configured on per-package basis. * This can be configured on per-package basis.
* *
* @param files the list of files * @param files the markdown files
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation includes(Collection<File> files) { public DokkaOperation includes(Collection<File> files) {
@ -483,7 +481,7 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
* @param configuration the configuration file path * @param configuration the configuration file path
*/ */
public DokkaOperation json(File configuration) { public DokkaOperation json(File configuration) {
json = configuration; json_ = configuration;
return this; return this;
} }
@ -648,26 +646,24 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
} }
/** /**
* 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 * @param jars one or more jars
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation pluginsClasspath(File... jars) { public DokkaOperation pluginsClasspath(File... jars) {
Collections.addAll(pluginsClasspath_, jars); pluginsClasspath_.addAll(List.of(jars));
return this; 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 * @param jars one or more jars
* @return this operation instance * @return this operation instance
*/ */
public DokkaOperation pluginsClasspath(String... jars) { public DokkaOperation pluginsClasspath(String... jars) {
Collections.addAll(pluginsClasspath_, Arrays.stream(jars) pluginsClasspath_.addAll(Arrays.stream(jars).map(File::new).toList());
.map(File::new)
.toArray(File[]::new));
return this; return this;
} }
@ -681,9 +677,9 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
} }
/** /**
* 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 * @return this operation instance
*/ */
public DokkaOperation pluginsClasspath(Collection<File> jars) { public DokkaOperation pluginsClasspath(Collection<File> jars) {

View file

@ -243,7 +243,7 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet classpath(File... files) { public SourceSet classpath(File... files) {
Collections.addAll(classpath_, files); classpath_.addAll(List.of(files));
return this; return this;
} }
@ -258,9 +258,7 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet classpath(String... files) { public SourceSet classpath(String... files) {
Collections.addAll(classpath_, Arrays.stream(files) classpath_.addAll(Arrays.stream(files).map(File::new).toList());
.map(File::new)
.toArray(File[]::new));
return this; return this;
} }
@ -271,7 +269,7 @@ public class SourceSet {
* <p> * <p>
* This option accepts both {@code .jar} and {@code .klib} files. * 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 * @return this operation instance
*/ */
public SourceSet classpath(Collection<File> files) { public SourceSet classpath(Collection<File> files) {
@ -349,7 +347,7 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet documentedVisibilities(DocumentedVisibility... visibilities) { public SourceSet documentedVisibilities(DocumentedVisibility... visibilities) {
documentedVisibilities_.addAll(Arrays.asList(visibilities)); documentedVisibilities_.addAll(List.of(visibilities));
return this; return this;
} }
@ -402,7 +400,7 @@ public class SourceSet {
/** /**
* Sets the Markdown files that contain module and package documentation. * Sets the Markdown files that contain module and package documentation.
* <p> * <p>
* A list of Markdown files that contain module and package documentation. * The Markdown files that contain module and package documentation.
* <p> * <p>
* The contents of the specified files are parsed and embedded into documentation as module and package * The contents of the specified files are parsed and embedded into documentation as module and package
* descriptions. * descriptions.
@ -411,14 +409,14 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet includes(File... files) { public SourceSet includes(File... files) {
Collections.addAll(includes_, files); includes_.addAll(List.of(files));
return this; return this;
} }
/** /**
* Sets the Markdown files that contain module and package documentation. * Sets the Markdown files that contain module and package documentation.
* <p> * <p>
* A list of Markdown files that contain module and package documentation. * The Markdown files that contain module and package documentation.
* <p> * <p>
* The contents of the specified files are parsed and embedded into documentation as module and package * The contents of the specified files are parsed and embedded into documentation as module and package
* descriptions. * descriptions.
@ -427,9 +425,7 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet includes(String... files) { public SourceSet includes(String... files) {
Collections.addAll(includes_, Arrays.stream(files) includes_.addAll(Arrays.stream(files).map(File::new).toList());
.map(File::new)
.toArray(File[]::new));
return this; return this;
} }
@ -445,12 +441,12 @@ public class SourceSet {
/** /**
* Sets the Markdown files that contain module and package documentation. * Sets the Markdown files that contain module and package documentation.
* <p> * <p>
* A list of Markdown files that contain module and package documentation. * The Markdown files that contain module and package documentation.
* <p> * <p>
* The contents of the specified files are parsed and embedded into documentation as module and package * The contents of the specified files are parsed and embedded into documentation as module and package
* descriptions. * descriptions.
* *
* @param files the list of files * @param files the collection of files
* @return this operation instance * @return this operation instance
*/ */
public SourceSet includes(Collection<File> files) { public SourceSet includes(Collection<File> files) {
@ -559,7 +555,7 @@ public class SourceSet {
} }
/** /**
* Set the list of package source set configuration. * Set the package source set configuration.
* <p> * <p>
* A set of parameters specific to matched packages within this source set. * A set of parameters specific to matched packages within this source set.
* <p> * <p>
@ -574,7 +570,7 @@ public class SourceSet {
* <li>...</li> * <li>...</li>
* </ul> * </ul>
* *
* @param perPackageOptions the list of per package options * @param perPackageOptions the per package options
* @return this operation instance * @return this operation instance
*/ */
public SourceSet perPackageOptions(Collection<String> perPackageOptions) { public SourceSet perPackageOptions(Collection<String> 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 * @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.
* <p> * <p>
* A set of parameters specific to matched packages within this source set. * A set of parameters specific to matched packages within this source set.
* <p> * <p>
@ -607,11 +603,11 @@ public class SourceSet {
* <li>...</li> * <li>...</li>
* </ul> * </ul>
* *
* @param perPackageOptions the list of per package options * @param perPackageOptions the per package options
* @return this operation instance * @return this operation instance
*/ */
public SourceSet perPackageOptions(String... perPackageOptions) { public SourceSet perPackageOptions(String... perPackageOptions) {
Collections.addAll(perPackageOptions_, perPackageOptions); perPackageOptions_.addAll(List.of(perPackageOptions));
return this; 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.
* <p> * <p>
* 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. * tag.
* *
* @param samples the list of samples * @param samples the samples
* @return this operation instance * @return this operation instance
*/ */
public SourceSet samples(Collection<File> samples) { public SourceSet samples(Collection<File> 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 * @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.
* <p> * <p>
* 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. * tag.
* *
* @param samples nne or more samples * @param samples nne or more samples
* @return this operation instance * @return this operation instance
*/ */
public SourceSet samples(File... samples) { public SourceSet samples(File... samples) {
Collections.addAll(samples_, samples); samples_.addAll(List.of(samples));
return this; return this;
} }
/** /**
* Set the list of directories or files that contain sample functions. * Set the directories or files that contain sample functions.
* <p> * <p>
* 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. * tag.
* *
* @param samples nne or more samples * @param samples nne or more samples
* @return this operation instance * @return this operation instance
*/ */
public SourceSet samples(String... samples) { public SourceSet samples(String... samples) {
Collections.addAll(samples_, Arrays.stream(samples) samples_.addAll(Arrays.stream(samples).map(File::new).toList());
.map(File::new)
.toArray(File[]::new));
return this; return this;
} }
@ -718,7 +712,7 @@ public class SourceSet {
* The source code roots to be analyzed and documented. Acceptable inputs are directories and individual * The source code roots to be analyzed and documented. Acceptable inputs are directories and individual
* {@code .kt} / {@code .java} files. * {@code .kt} / {@code .java} files.
* *
* @param src the list of source code roots * @param src the source code roots
* @return this operation instance * @return this operation instance
*/ */
public SourceSet src(Collection<File> src) { public SourceSet src(Collection<File> src) {
@ -736,7 +730,7 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet src(File... src) { public SourceSet src(File... src) {
Collections.addAll(src_, src); src_.addAll(List.of(src));
return this; return this;
} }
@ -750,9 +744,7 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet src(String... src) { public SourceSet src(String... src) {
Collections.addAll(src_, Arrays.stream(src) src_.addAll(Arrays.stream(src).map(File::new).toList());
.map(File::new)
.toArray(File[]::new));
return this; return this;
} }
@ -805,7 +797,7 @@ public class SourceSet {
* <p> * <p>
* The files to be suppressed when generating documentation. * The files to be suppressed when generating documentation.
* *
* @param suppressedFiles the list of suppressed files * @param suppressedFiles the suppressed files
* @return this operation instance * @return this operation instance
*/ */
public SourceSet suppressedFiles(Collection<File> suppressedFiles) { public SourceSet suppressedFiles(Collection<File> suppressedFiles) {
@ -832,9 +824,7 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet suppressedFiles(String... suppressedFiles) { public SourceSet suppressedFiles(String... suppressedFiles) {
Collections.addAll(suppressedFiles_, Arrays.stream(suppressedFiles) suppressedFiles_.addAll(Arrays.stream(suppressedFiles).map(File::new).toList());
.map(File::new)
.toArray(File[]::new));
return this; return this;
} }
@ -847,7 +837,7 @@ public class SourceSet {
* @return this operation instance * @return this operation instance
*/ */
public SourceSet suppressedFiles(File... suppressedFiles) { public SourceSet suppressedFiles(File... suppressedFiles) {
suppressedFiles_.addAll(Arrays.asList(suppressedFiles)); suppressedFiles_.addAll(List.of(suppressedFiles));
return this; return this;
} }
} }