Package org.metricshub.winrm
Class Utils
java.lang.Object
org.metricshub.winrm.Utils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckArgumentNotZeroOrNegative(long argument, String name) Check if the required argument is not negative or zero.static voidcheckNonBlank(String argument, String name) Check if the required argument is not blank (null or empty).static <T> voidcheckNonNull(T argument, String name) Check if the required argument is not null.static <T> voidcheckNonNullField(T field, String name) Check if the required field is not null.static <T> TRun the givenCallableusing the passed timeout in seconds.static Stringstatic longGet the current time in Milliseconds.static booleanstatic booleanstatic booleanisNotBlank(String value) static voidsleep(long millis) Wrapper for Thread.sleep(millis)
-
Field Details
-
EMPTY
- See Also:
-
NEW_LINE
- See Also:
-
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
checkNonNull
Check if the required argument is not null.- Parameters:
argument-name-- Throws:
IllegalArgumentException- if the argument is null
-
isBlank
- Parameters:
value- The value to check- Returns:
- whether the value is null, empty or contains only blank chars
-
isEmpty
- Parameters:
value- The value to check- Returns:
- whether the value is empty of non-blank chars
- Throws:
NullPointerException- if value is null
-
isNotBlank
- Parameters:
value- The value to check- Returns:
- whether the value is not null, nor empty nor contains only blank chars
-
getComputerName
- Returns:
- the name of the local computer (or "localhost" if it can't be determined)
-
sleep
Wrapper for Thread.sleep(millis)- Parameters:
millis- Time to sleep (in milliseconds)- Throws:
InterruptedException
-
checkArgumentNotZeroOrNegative
Check if the required argument is not negative or zero.- Parameters:
argument-name-- Throws:
IllegalArgumentException- if the argument is null
-
getCurrentTimeMillis
public static long getCurrentTimeMillis()Get the current time in Milliseconds.- Returns:
- the current time in Milliseconds.
-
checkNonBlank
Check if the required argument is not blank (null or empty).- Parameters:
argument-name-- Throws:
IllegalArgumentException- if the argument is null
-
execute
public static <T> T execute(Callable<T> callable, long timeout) throws InterruptedException, ExecutionException, TimeoutException Run the givenCallableusing the passed timeout in seconds.- Type Parameters:
T-- Parameters:
callable-timeout-- Returns:
Utilsresult returned by the callable- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
checkNonNullField
Check if the required field is not null.- Parameters:
field-name-- Throws:
IllegalStateException- if the argument is null
-