Class HelpersKt

  • All Implemented Interfaces:

    
    public final class HelpersKt
    
                        
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final static Map<String, String> properties(URL url) Load a '*.properties' file from a URL transforming the content into a plain map.
      final static <T extends Any> T retry(Integer times, Long delay, Function0<T> block) Execute a lambda until no exception is thrown or a number of times is reached.
      final static String exec(List<String> $self, File workingDirectory, Long timeout, Boolean fail) TODO.
      final static String exec(String $self, File workingDirectory, Long timeout, Boolean fail) TODO Add use case and example in documentation.
      final static String shell(String $self, File workingDirectory, Long timeout, Boolean fail) Executes a command in a shell (allowing to use pipes, redirections, etc.).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • properties

         final static Map<String, String> properties(URL url)

        Load a '*.properties' file from a URL transforming the content into a plain map. If the resource can not be found, a com.hexagonkt.core.ResourceNotFoundException is thrown.

        Parameters:
        url - URL pointing to the file to load.
        Returns:

        Map containing the properties file data.

      • retry

         final static <T extends Any> T retry(Integer times, Long delay, Function0<T> block)

        Execute a lambda until no exception is thrown or a number of times is reached.

        Parameters:
        times - Number of times to try to execute the callback.
        delay - Milliseconds to wait to next execution if there was an error.
        block - Code to be executed.
        Returns:

        Callback's result if succeeded.

      • exec

         final static String exec(List<String> $self, File workingDirectory, Long timeout, Boolean fail)

        TODO.

        TODO Assure JVM closes properly after process execution (dispose process resources, etc.)

      • exec

         final static String exec(String $self, File workingDirectory, Long timeout, Boolean fail)

        TODO Add use case and example in documentation. TODO Support multiple words parameters by processing " and '

        Run the receiver's text as a process in the host operating system. The command can have multiple lines and may or may not contain the shell continuation string (\\n).

        Parameters:
        workingDirectory - Directory on which the process will be executed.
        timeout - Maximum number of seconds allowed for process execution.
        fail - If true Raise an exception if the result code is different from zero.
        Returns:

        The output of the command.

      • shell

         final static String shell(String $self, File workingDirectory, Long timeout, Boolean fail)

        Executes a command in a shell (allowing to use pipes, redirections, etc.).

        TODO