public class Js extends Object
| Constructor and Description |
|---|
Js() |
| Modifier and Type | Method and Description |
|---|---|
static <T> com.fasterxml.jackson.databind.JsonNode |
asJson(T... pairs)
Creates a json from variadic value pairs
|
static <T,U> Map<T,U> |
asMap(org.apache.commons.lang3.tuple.Pair<T,U>... pairs)
Creates a hash map from variadic value pairs
|
static <T> Map<T,T> |
asMap(T... pairs)
Creates a hash map from variadic value pairs
|
static void |
log(Object... data) |
static <T> T |
or(T... values)
Alternative to JavaScript a || b || c ...
|
static <U,T> U |
reduce(List<T> list,
java.util.function.BiFunction<U,T,U> reducer,
U initialValue)
JavaScript-like reduce
|
static Timer |
setInterval(Runnable callback,
int msInterval)
Setups interval with JavaScript-like syntax
|
static Timer |
setTimeout(Runnable callback,
int msInterval)
Setups timeout with JavaScript-like syntax
|
static void |
sleep(int milliseconds)
Executes thread sleep with error handling
|
static void |
trace(Object data)
Logs specified data and its stack trace
|
public static <U,T> U reduce(List<T> list, java.util.function.BiFunction<U,T,U> reducer, U initialValue)
U - Type of the accumulated valueT - Type of list elements to reduce fromlist - list to reducereducer - reducer functioninitialValue - initial value@SafeVarargs public static <T> T or(T... values)
T - Type of valuesvalues - Values to select fromnull@SafeVarargs public static <T,U> Map<T,U> asMap(org.apache.commons.lang3.tuple.Pair<T,U>... pairs)
T - Type of the map keysU - Type of the map valuespairs - Key-Value pairs@SafeVarargs public static <T> Map<T,T> asMap(T... pairs)
T - Type of the map keys and valuespairs - Key-Value pairs@SafeVarargs public static <T> com.fasterxml.jackson.databind.JsonNode asJson(T... pairs)
T - Type of the json keys and valuespairs - Key-Value pairspublic static Timer setTimeout(Runnable callback, int msInterval)
callback - Callback to runmsInterval - Timeout in millisecondspublic static Timer setInterval(Runnable callback, int msInterval)
callback - Callback to runmsInterval - Interval in millisecondspublic static void sleep(int milliseconds)
milliseconds - Milliseonds to sleeppublic static void log(Object... data)
public static void trace(Object data)
data - Data to printCopyright © 2022. All rights reserved.