Package dev.comfast.util
Class Utils
java.lang.Object
dev.comfast.util.Utils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanstatic voidsleep(long ms)Unchecked sleep.transposeMatrix(List<List<T>> matrix)static StringtrimString(Object input, int maxLength)static voidwithSystemProp(String systemPropertyName, Runnable func)Restore system property after func is done.
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
sleep
public static void sleep(long ms)Unchecked sleep. CheckedInterruptedExceptionis wrapped intoRuntimeException. -
trimString
- Parameters:
input- string or objectmaxLength- max length of result string- Returns:
- First characters from input string
-
transposeMatrix
- Parameters:
matrix- list of lists eg.["1", "2", "3", "4"], ["5", "6", "7", "8"]- Returns:
- transposed list of lists, eg.
["1", "5"], ["2", "6"], ["3", "7"], ["4", "8"],
-
withSystemProp
Restore system property after func is done. It's safe to edit it inside given function, for test purposes or any other. e.g.// here "my.timeout" is 3000 withSystemProp("my.timeout", () -> { System.setProperty("my.timeout", "0"); doSomeTests(); }) // here "my.timeout" is restored to 3000- Parameters:
func- within this function can edit system prop freely without side effects for the rest of the code }
-
isTruthly
- Parameters:
input- any object- Returns:
- false if null, false, 0, trimmed empty string
-