public class Util
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.util.regex.Pattern |
DECIMAL_PATTERN
A pattern to check if a string is a decimal number.
|
static java.util.regex.Pattern |
INT_PATTERN
A pattern to check if a string is an integer number.
|
| Constructor and Description |
|---|
Util() |
| Modifier and Type | Method and Description |
|---|---|
static <E> ArgumentRequirement<E> |
and(ArgumentRequirement<E>... predicates)
And chain multiple argument requirements.
|
static java.lang.String |
beautify(java.lang.Enum<?> value,
boolean addSpaces)
Beautify the name of an enum value.
|
static <T> T |
cast(java.lang.Object o)
Cast anything to anything else.
|
static <T> java.util.Optional<T> |
ofThrowing(ThrowingSupplier<T> supplier)
Get an optional from a throwing supplier.
|
static void |
prepend(java.util.Set<java.lang.String> set,
java.lang.String prefix)
Prepend all strings in a set with a prefix.
|
static <K,V> java.util.LinkedHashMap<K,V> |
sortMap(java.util.Map<K,V> map,
java.util.Comparator<java.util.Map.Entry<K,V>> comparator)
Sort a map by a comparator.
|
public static final java.util.regex.Pattern INT_PATTERN
public static final java.util.regex.Pattern DECIMAL_PATTERN
public static <T> java.util.Optional<T> ofThrowing(ThrowingSupplier<T> supplier)
T - The type of the optionalsupplier - The supplierpublic static <T> T cast(java.lang.Object o)
T - The type to cast too - The object to castjava.lang.ClassCastException - If the cast is not possiblepublic static <K,V> java.util.LinkedHashMap<K,V> sortMap(java.util.Map<K,V> map,
java.util.Comparator<java.util.Map.Entry<K,V>> comparator)
K - The key typeV - The value typemap - The map to sortcomparator - The comparator to sort bypublic static void prepend(java.util.Set<java.lang.String> set,
java.lang.String prefix)
set - The set to prependprefix - The prefix to prependpublic static java.lang.String beautify(java.lang.Enum<?> value,
boolean addSpaces)
value - The enum valueaddSpaces - If spaces should be addedpublic static <E> ArgumentRequirement<E> and(ArgumentRequirement<E>... predicates)
E - The type of the predicatepredicates - The predicates to check