public class MiscUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
assertState(boolean state,
String message)
Asserts that a tested state is true, throwing an IllegalStateException if not.
|
static void |
assertState(boolean state,
Supplier<String> message)
Asserts that a tested state is true, throwing an IllegalStateException if not.
|
static void |
assertTrue(boolean condition,
String message)
Asserts that a condition is true, throwing an IllegalArgumentException if not.
|
static void |
assertTrue(boolean condition,
Supplier<String> message)
Asserts that a tested condition is true, throwing an IllegalArgumentException if not.
|
static <T> T |
castTo(Object value,
Class<T> type)
Casts a value to the specified type, returning null if the cast is not possible.
|
static boolean |
fileExists(String fileName)
Returns true if the specified file exists.
|
static Class<?> |
firstAssignable(Class<?> type,
Class<?>... candidates)
Returns the first class from a list of candidate classes that is assignable from the specified
type.
|
static Class<?> |
firstAssignable(Class<?> type,
Collection<Class<?>> candidates)
Returns the first class in a collection of candidate classes that is assignable from the specified
type.
|
static Class<?>[] |
getParameterTypes(Object... parameters)
Returns an array of parameter types given an array of parameters.
|
static Pattern |
globToRegex(String glob)
Converts a glob search pattern to a regular expression.
|
static RuntimeException |
toUnchecked(Throwable e)
Converts a checked exception to unchecked.
|
public static boolean fileExists(String fileName)
fileName - File name.public static RuntimeException toUnchecked(Throwable e)
e - The original exception.public static Class<?>[] getParameterTypes(Object... parameters)
parameters - Array of parameters.public static <T> T castTo(Object value, Class<T> type)
T - The type to cast to.value - The value to cast.type - The type to cast to.public static Class<?> firstAssignable(Class<?> type, Class<?>... candidates)
type - The type.candidates - A list of candidate types.public static Class<?> firstAssignable(Class<?> type, Collection<Class<?>> candidates)
type - The type.candidates - A collection of candidate types.public static Pattern globToRegex(String glob)
glob - Glob search pattern.public static void assertTrue(boolean condition,
String message)
condition - The condition to test.message - The exception message.IllegalArgumentException - if condition is false.public static void assertTrue(boolean condition,
Supplier<String> message)
condition - The tested condition.message - The exception message.IllegalArgumentException - if condition is false.public static void assertState(boolean state,
String message)
state - The tested state.message - The exception message.IllegalStateException - if state is false.public static void assertState(boolean state,
Supplier<String> message)
state - The tested state.message - The exception message.IllegalStateException - if state is false.Copyright © 2020 Fujion Framework. All rights reserved.