Package 

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
      private static Boolean disableChecks
      private final static InetAddress allInterfaces
      private final static Void fail
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      Boolean getDisableChecks() Disable heavy and optional checks in runtime.
      void setDisableChecks(Boolean disableChecks) Disable heavy and optional checks in runtime.
      final InetAddress getAllInterfaces() Internet address used to bind services to all local network interfaces.
      final Void getFail()
      final static <T extends Any> T println(T $self, String prefix) Print receiver to stdout.
      final static <T extends ResourceBundle> ResourceBundle resourceBundle(Locale locale) TODO.
      final static <T extends ResourceBundle> ResourceBundle resourceBundle(KClass<T> type, Locale locale) TODO.
      final static InetAddress inetAddress(Byte bytes) Syntactic sugar to create an Internet address.
      final static Integer freePort() Return a random free port (not used by any other local process).
      final static Boolean isPortOpened(Integer port) Check if a port is already opened.
      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 Unit check(String message, Function0<Unit> blocks) TODO.
      final static Array<out StackTraceElement> filterStackTrace(Throwable $self, String prefix) Return the stack trace array of the frames that starts with the given prefix.
      final static String toText(Throwable $self, String prefix) Return this throwable as a text.
      final static <Z extends Any> Collection<Z> ensureSize(Collection<Z> $self, IntRange count) TODO.
      final static <T extends Any> T keys(Map<?, ?> $self, Object keys) TODO.
      final static <T extends Any> T invoke(Map<?, ?> $self, Object keys) TODO.
      final static <T extends Any> T requireKeys(Map<?, ?> $self, Object name) TODO.
      final static <T extends Any> Map<String, ?> fieldsMapOf(Pair<KProperty1<T, ?>, ?> fields) TODO.
      final static <K extends Any, V extends Any> V require(Map<K, V> $self, K name) TODO.
      final static <K extends Any, V extends Any> Map<K, V> filterEmpty(Map<K, V> $self) TODO.
      final static <V extends Any> List<V> filterEmpty(List<V> $self) TODO.
      final static Map<?, ?> filterEmptyRecursive(Map<?, ?> $self) TODO.
      final static List<?> filterEmptyRecursive(List<?> $self) TODO.
      final static <V extends Any> Boolean notEmpty(V value) TODO.
      • Methods inherited from class java.lang.Object

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

    • Method Detail

      • getDisableChecks

         Boolean getDisableChecks()

        Disable heavy and optional checks in runtime. This flag can be enabled to get a small performance boost. Do NOT do this on development (it could mask problems) and enable it on production only if you have tested your application extensively.

        It's initial value is taken from the DISABLE_CHECKS flag. See Jvm.systemFlag for details on how flags are checked on a JVM.

        This variable can be changed on code to affect only certain parts of the code, however this is not advised and should be done carefully.

      • setDisableChecks

         void setDisableChecks(Boolean disableChecks)

        Disable heavy and optional checks in runtime. This flag can be enabled to get a small performance boost. Do NOT do this on development (it could mask problems) and enable it on production only if you have tested your application extensively.

        It's initial value is taken from the DISABLE_CHECKS flag. See Jvm.systemFlag for details on how flags are checked on a JVM.

        This variable can be changed on code to affect only certain parts of the code, however this is not advised and should be done carefully.

      • getAllInterfaces

         final InetAddress getAllInterfaces()

        Internet address used to bind services to all local network interfaces.

      • println

         final static <T extends Any> T println(T $self, String prefix)

        Print receiver to stdout. Convenient utility to debug variables quickly.

        Parameters:
        prefix - String to print before the actual object information.
      • resourceBundle

         final static <T extends ResourceBundle> ResourceBundle resourceBundle(Locale locale)
        Parameters:
        locale - .
      • resourceBundle

         final static <T extends ResourceBundle> ResourceBundle resourceBundle(KClass<T> type, Locale locale)
        Parameters:
        type - .
        locale - .
      • inetAddress

         final static InetAddress inetAddress(Byte bytes)

        Syntactic sugar to create an Internet address.

        Parameters:
        bytes - Bytes used in the address.
      • freePort

         final static Integer freePort()

        Return a random free port (not used by any other local process).

      • isPortOpened

         final static Boolean isPortOpened(Integer port)

        Check if a port is already opened.

        Parameters:
        port - Port number to check.
      • 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.
      • 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 than zero.
      • check

         final static Unit check(String message, Function0<Unit> blocks)
      • filterStackTrace

         final static Array<out StackTraceElement> filterStackTrace(Throwable $self, String prefix)

        Return the stack trace array of the frames that starts with the given prefix.

        Parameters:
        prefix - Prefix used to filter stack trace elements (applied to class names).
      • toText

         final static String toText(Throwable $self, String prefix)

        Return this throwable as a text.

        Parameters:
        prefix - Optional prefix to filter stack trace elements.
      • ensureSize

         final static <Z extends Any> Collection<Z> ensureSize(Collection<Z> $self, IntRange count)
        Parameters:
        count - .
      • keys

         final static <T extends Any> T keys(Map<?, ?> $self, Object keys)
        Parameters:
        keys - .
      • invoke

         final static <T extends Any> T invoke(Map<?, ?> $self, Object keys)
        Parameters:
        keys - .
      • requireKeys

         final static <T extends Any> T requireKeys(Map<?, ?> $self, Object name)
        Parameters:
        name - .
      • fieldsMapOf

         final static <T extends Any> Map<String, ?> fieldsMapOf(Pair<KProperty1<T, ?>, ?> fields)
        Parameters:
        fields - .
      • require

         final static <K extends Any, V extends Any> V require(Map<K, V> $self, K name)
        Parameters:
        name - .
      • filterEmpty

         final static <K extends Any, V extends Any> Map<K, V> filterEmpty(Map<K, V> $self)
      • filterEmpty

         final static <V extends Any> List<V> filterEmpty(List<V> $self)
      • notEmpty

         final static <V extends Any> Boolean notEmpty(V value)
        Parameters:
        value - .