Package ru.dest.library.utils
Class Utils
- java.lang.Object
-
- ru.dest.library.utils.Utils
-
public class Utils extends Object
-
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static @NotNull StringargsToString(String @NotNull [] args)Transforms string array to a single stringstatic @NotNull StringargsToString(String @NotNull [] args, int startPos)Transforms string array to a single string with start positionstatic @NotNull StringargsToString(String @NotNull [] args, int startPos, String separator)static @NotNull StringargsToString(String @NotNull [] args, String separator)static @NotNull StringcollectionToString(@NotNull Collection<String> collection)TransformsCollectionofStringto a single stringstatic @NotNull StringcollectionToString(@NotNull Collection<String> collection, String separator)TransformsCollectionofStringto a single string with specified separatorstatic @NotNull StringcollectionToString(@NotNull List<String> collection, int startPos)static @NotNull StringcollectionToString(@NotNull List<String> collection, int startPos, String separator)static @NotNull StringcollectionToString(@NotNull List<String> collection, String separator)static <T> voidexecuteIf(T t, @NotNull Consumer<T> c, @NotNull Predicate<T> p)Call consumer if result of givenPredicateequals truestatic <T> voidforEachIf(@NotNull Collection<T> collection, @NotNull Consumer<T> c, @NotNull Predicate<T> p)Call consumer if result of givenPredicateequals truestatic <T> @NotNull List<T>newList(T... values)Convert given objects array to list of objects;
-
-
-
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 stringsstartPos- - 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)
TransformsCollectionofStringto 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)
TransformsCollectionofStringto a single string with specified separator- Parameters:
collection- - collection of stringsseparator- - separator- Returns:
- resulting string
-
collectionToString
@NotNull public static @NotNull String collectionToString(@NotNull @NotNull List<String> collection, int startPos)
- Parameters:
collection- - collection of stringsstartPos- - 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)
- Parameters:
collection- - collection of stringsseparator- - separator- Returns:
- resulting string
-
collectionToString
@NotNull public static @NotNull String collectionToString(@NotNull @NotNull List<String> collection, int startPos, String separator)
- Parameters:
collection- - collection of stringsseparator- - separatorstartPos- - 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 givenPredicateequals true- Type Parameters:
T- type of checking object- Parameters:
t- object which will be checkedc- consumer which will be calledp- 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 givenPredicateequals true- Type Parameters:
T- type of checking object- Parameters:
collection-Collectionof objects which will be checkedc- consumer which will be calledp- checking condition
-
-