Class Utils


  • public class Utils
    extends Object
    • Constructor Detail

      • Utils

        public Utils()
    • Method Detail

      • argsToString

        @NotNull
        public static @NotNull String argsToString​(String @NotNull [] args)
        Transforms string array to a single string
        Parameters:
        args - - array of strings
        Returns:
        resulting string
      • argsToString

        @NotNull
        public static @NotNull String argsToString​(String @NotNull [] args,
                                                   int startPos)
        Transforms string array to a single string with start position
        Parameters:
        args - - array of strings
        startPos - - number of the element from which need start
        Returns:
        resulting string
      • argsToString

        @NotNull
        public static @NotNull String argsToString​(String @NotNull [] args,
                                                   String separator)
      • argsToString

        @NotNull
        public static @NotNull String argsToString​(String @NotNull [] args,
                                                   int startPos,
                                                   String separator)
      • collectionToString

        @NotNull
        public static @NotNull String collectionToString​(@NotNull
                                                         @NotNull Collection<String> collection)
        Transforms Collection of String to a single string
        Parameters:
        collection - - collection of strings
        Returns:
        resulting string
      • collectionToString

        @NotNull
        public static @NotNull String collectionToString​(@NotNull
                                                         @NotNull Collection<String> collection,
                                                         String separator)
        Transforms Collection of String to a single string with specified separator
        Parameters:
        collection - - collection of strings
        separator - - separator
        Returns:
        resulting string
      • collectionToString

        @NotNull
        public static @NotNull String collectionToString​(@NotNull
                                                         @NotNull List<String> collection,
                                                         int startPos)
        Transforms List of String to a single string with start position
        Parameters:
        collection - - collection of strings
        startPos - - number of the element from which need start
        Returns:
        resulting string
      • collectionToString

        @NotNull
        public static @NotNull String collectionToString​(@NotNull
                                                         @NotNull List<String> collection,
                                                         String separator)
        Transforms List of String to a single string with specified separator
        Parameters:
        collection - - collection of strings
        separator - - separator
        Returns:
        resulting string
      • collectionToString

        @NotNull
        public static @NotNull String collectionToString​(@NotNull
                                                         @NotNull List<String> collection,
                                                         int startPos,
                                                         String separator)
        Transforms List of String to a single string with specified separator and start position
        Parameters:
        collection - - collection of strings
        separator - - separator
        startPos - - number of element from which we need to start
        Returns:
        resulting string
      • newList

        @SafeVarargs
        @Contract("_ -> new")
        @NotNull
        public static <T> @NotNull List<T> newList​(T... values)
        Convert given objects array to list of objects;
        Type Parameters:
        T - type of objects;
        Parameters:
        values - - list of objects
        Returns:
        list of given objects;
      • executeIf

        public static <T> void executeIf​(@NotNull
                                         T t,
                                         @NotNull
                                         @NotNull Consumer<T> c,
                                         @NotNull
                                         @NotNull Predicate<T> p)
        Call consumer if result of given Predicate equals true
        Type Parameters:
        T - type of checking object
        Parameters:
        t - object which will be checked
        c - consumer which will be called
        p - checking condition
      • forEachIf

        public static <T> void forEachIf​(@NotNull
                                         @NotNull Collection<T> collection,
                                         @NotNull
                                         @NotNull Consumer<T> c,
                                         @NotNull
                                         @NotNull Predicate<T> p)
        Call consumer if result of given Predicate equals true
        Type Parameters:
        T - type of checking object
        Parameters:
        collection - Collection of objects which will be checked
        c - consumer which will be called
        p - checking condition