public final class Exceptions extends Object
Validate class.| Modifier and Type | Method and Description |
|---|---|
static void |
allNotNull(Object... check)
Throws an
IllegalArgumentException if any of the passed arguments
are null |
static void |
allNotNull(String message,
Object... check)
Throws an
IllegalArgumentException if any of the passed arguments
are null |
static void |
illegalInvocation(boolean state)
|
static void |
illegalInvocation(boolean state,
String message)
|
static void |
illegalState(boolean state)
|
static void |
illegalState(boolean state,
String message)
|
static <T extends RuntimeException> |
isTrue(boolean validate,
Class<T> ex)
Validates a statement is
true, and throws a custom
RuntimeException as specified by the passed class parameter |
static <T extends RuntimeException> |
isTrue(boolean validate,
String message,
Class<T> ex)
Validates a statement is
true, and throws a custom
RuntimeException as specified by the passed class parameter |
static <T extends RuntimeException> |
notNull(Object obj,
Class<T> ex)
Provides a null check, and throws a custom
RuntimeException as
specified by the passed class parameter |
static <T extends RuntimeException> |
notNull(Object obj,
String message,
Class<T> ex)
Provides a null check, and throws a custom
RuntimeException as
specified by the passed class parameter |
static String |
readableStackTrace(Throwable t)
Creates a readable stack trace from a passed
Throwable. |
static void |
unsupportedOperation(boolean state)
|
static void |
unsupportedOperation(boolean state,
String message)
|
public static void allNotNull(String message, Object... check)
IllegalArgumentException if any of the passed arguments
are nullmessage - The message to include in the exceptioncheck - The objects to checkIllegalArgumentException - if any checked passed argument is nullpublic static void allNotNull(Object... check)
IllegalArgumentException if any of the passed arguments
are nullcheck - The objects to checkIllegalArgumentException - if any passed argument is nullpublic static void illegalState(boolean state,
String message)
state - The conditional to verifymessage - The message to include in an IllegalStateExceptionIllegalStateException - if state is falsepublic static void illegalState(boolean state)
state - The conditional to verifyIllegalStateException - if state is falsepublic static void illegalInvocation(boolean state,
String message)
state - The conditional to verifymessage - The message to include in an
IllegalInvocationExceptionIllegalInvocationException - if state is falsepublic static void illegalInvocation(boolean state)
state - The conditional to verifyIllegalInvocationException - if state is falsepublic static void unsupportedOperation(boolean state,
String message)
state - The conditional to verifymessage - The message to include in an
UnsupportedOperationExceptionUnsupportedOperationException - if state is falsepublic static void unsupportedOperation(boolean state)
state - The conditional to verifyUnsupportedOperationException - if state is falsepublic static <T extends RuntimeException> void notNull(Object obj, String message, Class<T> ex)
RuntimeException as
specified by the passed class parameterT - The exception typeobj - The object to check for nullmessage - The message to add to the exception if obj is nullex - The RuntimeException class to instantiatepublic static <T extends RuntimeException> void notNull(Object obj, Class<T> ex)
RuntimeException as
specified by the passed class parameterT - The exception typeobj - The object to check for nullex - The RuntimeException class to instantiatepublic static <T extends RuntimeException> void isTrue(boolean validate, String message, Class<T> ex)
true, and throws a custom
RuntimeException as specified by the passed class parameterT - The exception typevalidate - The boolean to evaluatemessage - The message to add to the exception if obj is nullex - The RuntimeException class to instantiatepublic static <T extends RuntimeException> void isTrue(boolean validate, Class<T> ex)
true, and throws a custom
RuntimeException as specified by the passed class parameterT - The exception typevalidate - The boolean to evaluateex - The RuntimeException class to instantiatepublic static String readableStackTrace(Throwable t)
Throwable. This
method will reproduce the same output that
Throwable.printStackTrace() would outputt - The Throwable to make readableCopyright © 2017. All rights reserved.