- java.lang.Object
-
- de.carne.util.Check
-
public final class Check extends java.lang.ObjectUtility class providing code check related functions.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertTrue(boolean condition)Checks and ensures that a specific condition is met.static voidassertTrue(boolean condition, java.lang.String pattern, java.lang.Object... arguments)Checks and ensures that a specific condition is met.static java.lang.IllegalStateExceptionfail()Throws an IllegalStateException to indicate that an unexpected execution state occurred.static java.lang.IllegalStateExceptionfail(java.lang.String pattern, java.lang.Object... arguments)Throws an IllegalStateException to indicate that an unexpected execution state occurred.static <T> TisInstanceOf(@Nullable java.lang.Object object, java.lang.Class<T> type)Checks and ensures that an Object is an instance of a specific type.static <T> TisInstanceOf(@Nullable java.lang.Object object, java.lang.Class<T> type, java.lang.String pattern, java.lang.Object... arguments)Checks and ensures that an Object is an instance of a specific type.static voidisTrue(boolean condition)Checks and ensures that a specific condition is met.static voidisTrue(boolean condition, java.lang.String pattern, java.lang.Object... arguments)Checks and ensures that a specific condition is met.static java.lang.IllegalStateExceptionunexpected(java.lang.Object object)Throws an IllegalStateException to indicate that an unexpected data object has been encountered.
-
-
-
Method Detail
-
isInstanceOf
public static <T> T isInstanceOf(@Nullable java.lang.Object object, java.lang.Class<T> type)Checks and ensures that an Object is an instance of a specific type.- Type Parameters:
T- the type to ensure.- Parameters:
object- the Object to check.type- the type to ensure.- Returns:
- the checked Object (casted to the checked type}).
- Throws:
java.lang.IllegalArgumentException- if the submitted argument is not an instance of the given type.
-
isInstanceOf
public static <T> T isInstanceOf(@Nullable java.lang.Object object, java.lang.Class<T> type, java.lang.String pattern, java.lang.Object... arguments)Checks and ensures that an Object is an instance of a specific type.The MessageFormat class is used to format an exception message in case the check fails.
- Type Parameters:
T- the type to ensure.- Parameters:
object- the Object to check.type- the type to ensure.pattern- the exception message pattern to use in case the check fails.arguments- the exception message arguments to use in case the check fails.- Returns:
- the checked Object (casted to the checked type}).
- Throws:
java.lang.IllegalArgumentException- if the submitted argument is not an instance of the given type.
-
isTrue
public static void isTrue(boolean condition)
Checks and ensures that a specific condition is met.- Parameters:
condition- the condition to check.- Throws:
java.lang.IllegalArgumentException- if the condition is not met.
-
isTrue
public static void isTrue(boolean condition, java.lang.String pattern, java.lang.Object... arguments)Checks and ensures that a specific condition is met.The MessageFormat class is used to format an exception message in case the check fails.
- Parameters:
condition- the condition to check.pattern- the exception message pattern to use in case the check fails.arguments- the exception message arguments to use in case the check fails.- Throws:
java.lang.IllegalArgumentException- if the condition is not met.
-
assertTrue
public static void assertTrue(boolean condition)
Checks and ensures that a specific condition is met.- Parameters:
condition- the condition to check.- Throws:
java.lang.IllegalStateException- if the condition is not met.
-
assertTrue
public static void assertTrue(boolean condition, java.lang.String pattern, java.lang.Object... arguments)Checks and ensures that a specific condition is met.The MessageFormat class is used to format an exception message in case the check fails.
- Parameters:
condition- the condition to check.pattern- the exception message pattern to use in case the check fails.arguments- the exception message arguments to use in case the check fails.- Throws:
java.lang.IllegalStateException- if the condition is not met.
-
fail
public static java.lang.IllegalStateException fail()
Throws an IllegalStateException to indicate that an unexpected execution state occurred.- Returns:
- Nothing (function never returns).
- Throws:
java.lang.IllegalStateException- any time this function is called.
-
fail
public static java.lang.IllegalStateException fail(java.lang.String pattern, java.lang.Object... arguments)Throws an IllegalStateException to indicate that an unexpected execution state occurred.The MessageFormat class is used to format an exception message in case the check fails.
- Parameters:
pattern- the exception message pattern to use in case the check fails.arguments- the exception message arguments to use in case the check fails.- Returns:
- Nothing (function never returns).
- Throws:
java.lang.IllegalStateException- any time this function is called.
-
unexpected
public static java.lang.IllegalStateException unexpected(java.lang.Object object)
Throws an IllegalStateException to indicate that an unexpected data object has been encountered.- Parameters:
object- the unexpected data object:- Returns:
- Nothing (function never returns).
- Throws:
java.lang.IllegalStateException- any time this function is called.
-
-