]> Git Server - utils.git/commitdiff
javadoc
authorRobin Cheney <cheneyr@eternal.ddnss.de>
Tue, 25 Nov 2025 13:13:33 +0000 (14:13 +0100)
committerRobin Cheney <cheneyr@eternal.ddnss.de>
Tue, 25 Nov 2025 13:13:33 +0000 (14:13 +0100)
src/main/java/de/ddnss/eternal/utils/io/input/Command.java
src/main/java/de/ddnss/eternal/utils/io/input/user/CMDCommands.java
src/main/java/de/ddnss/eternal/utils/threading/ParallelProcessor.java

index 9ba05fcf12e2b175d23b5f42b7a98fe5d4579771..b76ad3f274aad389738394c572e6cb6c9580a97c 100644 (file)
@@ -15,15 +15,16 @@ public class Command {
     /**
      * The command to be executed. Must be passed as a runnable to the constructor
      * or if parameters are necessary, it must be a {@link Function} that takes a
-     * {@link GenericCommandOption} as the single parameter and always returns null
+     * {@link CommandOption} as the single parameter and always returns null
      */
     final Function<CommandOption, Void> command;
     CommandOption arguments = new CommandOption();
 
     /**
+     * Create a command from a function with no return value
      * 
-     * @param command
-     * @param arguments
+     * @param command   The result-less function
+     * @param arguments The arguments for the function as a {@link CommandOption}
      */
     public Command(Function<CommandOption, Void> command, CommandOption arguments) {
         this.command = command;
@@ -31,8 +32,9 @@ public class Command {
     }
 
     /**
+     * Create a command from a function with no return value
      * 
-     * @param command A {@link Function} that takes a {@link GenericCommandOption}
+     * @param command A {@link Function} that takes a {@link CommandOption}
      */
     public Command(Function<CommandOption, Void> command) {
         this.command = command;
@@ -54,9 +56,9 @@ public class Command {
      * Execute the command with the previously provided arguments
      * 
      * @apiNote This method has a shorthand property where you can provide
-     *          {@link GenericCommandOption command options}
-     * @see #exec(GenericCommandOption)
-     * @see #bindArguments(GenericCommandOption)
+     *          {@link CommandOption command options}
+     * @see #exec(CommandOption)
+     * @see #bindArguments(CommandOption)
      */
     public void exec() {
         this.command.apply(arguments);
@@ -65,7 +67,7 @@ public class Command {
     /**
      * Binds arguments to the command
      * 
-     * @param args A {@link GenericCommandOption} object holding the command
+     * @param args A {@link CommandOption} object holding the command
      *             arguments and
      *             their values
      * @return the {@link Command} object itself
@@ -89,9 +91,9 @@ public class Command {
     };
 
     /**
-     * Executes a command with a {@link GenericCommandOption}
+     * Executes a command with a {@link CommandOption}
      * 
-     * @param arguments A {@link GenericCommandOption} object holding necessary
+     * @param arguments A {@link CommandOption} object holding necessary
      *                  parameters
      * @throws InvalidArgumentsError
      */
index ed99671182bec9fa8951ca28340bbbf956c44b8f..099a7bd9fd96d0c72c91e766aa9cc39da40e861d 100644 (file)
@@ -18,6 +18,8 @@ public class CMDCommands {
      * Creates a scanner that can and will read input and try to evaluate it as a
      * {@link Command}
      * 
+     * @param enumClass An enum that implements the {@link CommandEnumInterface}
+     * 
      * @see AvailableCommands
      */
     public static <E extends Enum<E> & CommandEnumInterface> void scan(Class<E> enumClass) {
index cea151d838ec56ef4667b6d83c6c07ccb4c3a7c0..b8742503d8ecfff1cd5272f682202793d2a26d78 100644 (file)
@@ -6,8 +6,22 @@ import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Supplier;
 
+/**
+ * Parallel batch processing utilities
+ * 
+ * @since 1.4.0
+ * 
+ * @author Robin Cheney
+ */
 public class ParallelProcessor {
 
+    /**
+     * Runs the given function ONCE in every thread using the given number of
+     * threads.
+     * 
+     * @param function The {@link Runnable} to execute for this task.
+     * @param threads  Max. number of threads to use
+     */
     public static void run(Runnable function, int threads) {
         ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(threads);
         for (int i = 0; i < threads; i++) {
@@ -18,6 +32,12 @@ public class ParallelProcessor {
     /**
      * Runs the given task repeatedly using the given number of threads until
      * the provided condition becomes true.
+     * 
+     * @param task          The {@link Runnable} to execute for this task.
+     * @param threads       Max. number of threads to use
+     * @param stopCondition stopping condition. pass a lambda function or a function
+     *                      reference to return a boolean value. {@code true} will
+     *                      stop execution, {@code false} will continue
      */
     public static void runUntil(Runnable task, int threads, Supplier<Boolean> stopCondition) {
         ExecutorService executor = Executors.newFixedThreadPool(threads);