public class E extends Object
Utility class to throw common exceptions
| Modifier and Type | Method and Description |
|---|---|
static RuntimeException |
asRuntimeException(Exception e)
Convert an Exception to RuntimeException
|
static UnexpectedEncodingException |
encodingException(UnsupportedEncodingException cause)
Wrap the
UnsupportedEncodingException into an UnexpectedEncodingException and throw it out. |
static void |
illegalArgumentIf(boolean tester)
|
static void |
illegalArgumentIf(boolean tester,
String msg)
|
static void |
illegalArgumentIf(boolean tester,
String msg,
Object... args)
|
static void |
illegalArgumentIfNot(boolean tester)
|
static void |
illegalArgumentIfNot(boolean tester,
String msg)
|
static void |
illegalArgumentIfNot(boolean tester,
String msg,
Object... args)
|
static void |
illegalStateIf(boolean tester)
|
static void |
illegalStateIf(boolean tester,
String msg)
|
static void |
illegalStateIf(boolean tester,
String msg,
Object... args)
|
static void |
illegalStateIfNot(boolean tester)
|
static void |
illegalStateIfNot(boolean tester,
String msg)
|
static void |
illegalStateIfNot(boolean tester,
String msg,
Object... args)
|
static InvalidArgException |
invalidArg()
Throws out an
InvalidArgException. |
static InvalidArgException |
invalidArg(String msg,
Object... args)
Throws out an
InvalidArgException with error message specified. |
static void |
invalidArgIf(boolean tester)
|
static void |
invalidArgIf(boolean tester,
String msg,
Object... args)
|
static void |
invalidArgIfNot(boolean tester)
|
static void |
invalidArgIfNot(boolean tester,
String msg,
Object... args)
|
static ConfigurationException |
invalidConfiguration(String message,
Object... args)
Throws out a
ConfigurationException with message specified. |
static ConfigurationException |
invalidConfiguration(Throwable cause,
String message,
Object... args)
Throws out a
ConfigurationException with cause and message specified. |
static void |
invalidConfigurationIf(boolean tester,
String msg,
Object... args)
|
static void |
invalidConfigurationIfNot(boolean tester,
String msg,
Object... args)
|
static InvalidRangeException |
invalidRange()
Throws out an
InvalidRangeException. |
static InvalidRangeException |
invalidRange(String msg,
Object... args)
Throws out an
InvalidRangeException with error message specified. |
static void |
invalidRangeIf(boolean tester)
|
static void |
invalidRangeIf(boolean tester,
String msg,
Object... args)
|
static void |
invalidRangeIfNot(boolean tester)
|
static void |
invalidRangeIfNot(boolean tester,
String msg,
Object... args)
|
static InvalidStateException |
invalidState()
Throws out an
InvalidStateException. |
static InvalidStateException |
invalidState(String msg,
Object... args)
Throws out an
InvalidStateException with message specified. |
static void |
invalidStateIf(boolean tester)
|
static void |
invalidStateIf(boolean tester,
String msg,
Object... args)
|
static UnexpectedIOException |
ioException(IOException cause)
Wrap the
IOException into UnexpectedIOException and throw it out. |
static UnexpectedIOException |
ioException(String msg,
Object... args)
Throws out an
UnexpectedIOException with error message specified. |
static void |
NPE(boolean tester)
|
static void |
NPE(Object o1)
|
static void |
NPE(Object o1,
Object o2)
|
static void |
NPE(Object o1,
Object o2,
Object o3)
|
static void |
NPE(Object o1,
Object o2,
Object o3,
Object... objects)
Throw out NullPointerException if any one of the passed objects is null.
|
static void |
npeIf(boolean tester)
|
static void |
npeIfNot(boolean tester)
|
static String |
stackTrace(Throwable t)
Returns the error stack trace of a
Throwable specified as a String. |
static ToBeImplemented |
tbd()
Throws out a
ToBeImplemented with message to be implemented. |
static ToBeImplemented |
tbd(String feature)
Throws out a
ToBeImplemented with feature specified. |
static UnexpectedException |
unexpected(String msg,
Object... args)
Throws out a
UnexpectedException with message specified. |
static UnexpectedException |
unexpected(Throwable cause)
Throws out a
UnexpectedException with cause specified. |
static UnexpectedException |
unexpected(Throwable cause,
String msg,
Object... args)
Throws out a
UnexpectedException with message and cause specified. |
static void |
unexpectedIf(boolean tester) |
static void |
unexpectedIf(boolean tester,
String msg,
Object... args)
|
static void |
unexpectedIfNot(boolean tester) |
static void |
unexpectedIfNot(boolean tester,
String msg,
Object... args)
Throws out a
UnexpectedException with message and cause specified when tester is not evaluated to true. |
static UnsupportedException |
unsupport()
Throws out an
UnsupportedException. |
static UnsupportedException |
unsupport(String msg,
Object... args)
Throws out an
UnsupportedException with error message specified. |
static void |
unsupportedIf(boolean tester)
|
static void |
unsupportedIf(boolean tester,
String msg)
|
static void |
unsupportedIf(boolean tester,
String msg,
Object... args)
|
static void |
unsupportedIfNot(boolean tester)
|
static void |
unsupportedIfNot(boolean tester,
String msg)
|
static void |
unsupportedIfNot(boolean tester,
String msg,
Object... args)
|
public static InvalidStateException invalidState()
Throws out an InvalidStateException.
public static InvalidStateException invalidState(String msg, Object... args)
Throws out an InvalidStateException with message specified.
public static void invalidStateIf(boolean tester)
Throws out an InvalidStateException when tester evaluated to true.
tester - when true then an InvalidStateException will be thrown outpublic static void invalidStateIf(boolean tester,
String msg,
Object... args)
Throws out an InvalidStateException when tester evaluated to true.
tester - when true then an InvalidStateException will be thrown out.msg - the message format templateargs - the message format argumentspublic static void NPE(Object o1)
Throws NullPointerException if o1 is null.
o1 - the object to be evaluated.public static void NPE(Object o1, Object o2)
Throws out NullPointerException if o1 or o2 is null.
o1 - the first object to be evaluatedo2 - the second object to be evaluatedpublic static void NPE(Object o1, Object o2, Object o3)
Throws out NullPointerException if o1 or o2 or o3 is null.
o1 - the first object to be evaluatedo2 - the second object to be evaluatedo3 - the third object to be evaluatedpublic static void NPE(Object o1, Object o2, Object o3, Object... objects)
Throw out NullPointerException if any one of the passed objects is null.
o1 - the first object to be evaluatedo2 - the second object to be evaluatedo3 - the third object to be evaluatedobjects - other object instances to be evaluatedpublic static void NPE(boolean tester)
Throws out a NullPointerException when tester evaluated to true.
tester - the condition to be evaluatedpublic static UnexpectedException unexpected(String msg, Object... args)
Throws out a UnexpectedException with message specified.
msg - the message format pattern.args - the message format argumentspublic static UnexpectedException unexpected(Throwable cause)
Throws out a UnexpectedException with cause specified.
cause - the cause of the unexpected exception.public static UnexpectedException unexpected(Throwable cause, String msg, Object... args)
Throws out a UnexpectedException with message and cause specified.
cause - the cause of the unexpected exception.msg - the error message format pattern.args - the error message format arguments.public static void unexpectedIf(boolean tester,
String msg,
Object... args)
Throws out a UnexpectedException with message and cause specified when tester is evaluated to true.
tester - when true then throw out the exception.msg - the error message format pattern.args - the error message format arguments.public static void unexpectedIf(boolean tester)
public static void unexpectedIfNot(boolean tester,
String msg,
Object... args)
Throws out a UnexpectedException with message and cause specified when tester is not evaluated to true.
tester - when false then throw out the exception.msg - the error message format pattern.args - the error message format arguments.public static void unexpectedIfNot(boolean tester)
public static UnexpectedIOException ioException(IOException cause)
Wrap the IOException into UnexpectedIOException and throw it out.
cause - the IOException.public static UnexpectedIOException ioException(String msg, Object... args)
Throws out an UnexpectedIOException with error message specified.
msg - the error message format patternargs - the error message format argumentspublic static UnexpectedEncodingException encodingException(UnsupportedEncodingException cause)
Wrap the UnsupportedEncodingException into an UnexpectedEncodingException and throw it out.
cause - the UnsupportedEncodingException.public static ConfigurationException invalidConfiguration(String message, Object... args)
Throws out a ConfigurationException with message specified.
message - the error message format pattern.args - the error message format arguments.public static ConfigurationException invalidConfiguration(Throwable cause, String message, Object... args)
Throws out a ConfigurationException with cause and message specified.
cause - the cause of the configuration error.message - the error message format pattern.args - the error message format arguments.public static void invalidConfigurationIf(boolean tester,
String msg,
Object... args)
Throws out a ConfigurationException with message specified if tester evaluated to true.
tester - when true then throw out the exceptionmsg - the error message format pattern.args - the error message format arguments.public static void invalidConfigurationIfNot(boolean tester,
String msg,
Object... args)
Throws out a ConfigurationException with message specified if tester evaluated to false.
tester - when false then throw out the exceptionmsg - the error message format pattern.args - the error message format arguments.public static ToBeImplemented tbd()
Throws out a ToBeImplemented with message to be implemented.
public static ToBeImplemented tbd(String feature)
Throws out a ToBeImplemented with feature specified.
The error message will be "${feature} to be implemented"
feature - the feature namepublic static InvalidArgException invalidArg()
Throws out an InvalidArgException.
public static void invalidArgIf(boolean tester)
Throws out an InvalidArgException when tester is true.
tester - when true then throws out the exceptionpublic static void invalidArgIfNot(boolean tester)
Throws out an InvalidArgException when tester is false.
tester - when false then throws out the exceptionpublic static InvalidArgException invalidArg(String msg, Object... args)
Throws out an InvalidArgException with error message specified.
msg - the error message format pattern.args - the error message format arguments.public static void invalidArgIf(boolean tester,
String msg,
Object... args)
Throws out an InvalidArgException with error message specified when tester is true.
tester - when true then throws out the exception.msg - the error message format pattern.args - the error message format arguments.public static void invalidArgIfNot(boolean tester,
String msg,
Object... args)
Throws out an InvalidArgException with error message specified when tester is false.
tester - when false then throws out the exception.msg - the error message format pattern.args - the error message format arguments.public static InvalidRangeException invalidRange()
Throws out an InvalidRangeException.
public static void invalidRangeIf(boolean tester)
Throws out an InvalidRangeException when tester is true.
tester - when true then throw out the exception.public static void invalidRangeIfNot(boolean tester)
Throws out an InvalidRangeException when tester is false.
tester - when false then throw out the exception.public static InvalidRangeException invalidRange(String msg, Object... args)
Throws out an InvalidRangeException with error message specified.
msg - the error message format pattern.args - the error message format arguments.public static void invalidRangeIf(boolean tester,
String msg,
Object... args)
Throws out an InvalidRangeException with error message specified when tester is true.
tester - when true then throw out the exceptionmsg - the error message format pattern.args - the error message format arguments.public static void invalidRangeIfNot(boolean tester,
String msg,
Object... args)
Throws out an InvalidRangeException with error message specified when tester is false.
tester - when false then throw out the exceptionmsg - the error message format pattern.args - the error message format arguments.public static void npeIf(boolean tester)
Throws out an NullPointerException when tester is true.
tester - when true then throw out the exception.public static void npeIfNot(boolean tester)
Throws out an NullPointerException when tester is false.
tester - when false then throw out the exception.public static UnsupportedException unsupport()
Throws out an UnsupportedException.
public static UnsupportedException unsupport(String msg, Object... args)
Throws out an UnsupportedException with error message specified.
msg - the error message format pattern.args - the error message format arguments.public static void unsupportedIf(boolean tester)
Throws out an UnsupportedException if tester is true.
tester - when true then throw out the exception.public static void unsupportedIfNot(boolean tester)
Throws out an UnsupportedException if tester is false.
tester - when false then throw out the exception.public static void unsupportedIf(boolean tester,
String msg)
Throws out an UnsupportedException with error message specified if tester is true.
tester - when true then throw out the exception.msg - the error message.public static void unsupportedIfNot(boolean tester,
String msg)
Throws out an UnsupportedException with error message specified if tester is false.
tester - when false then throw out the exception.msg - the error message.public static void unsupportedIf(boolean tester,
String msg,
Object... args)
Throws out an UnsupportedException with error message specified if tester is true.
tester - when true then throw out the exception.msg - the error message format pattern.args - the error message format arguments.public static void unsupportedIfNot(boolean tester,
String msg,
Object... args)
Throws out an UnsupportedException with error message specified if tester is false.
tester - when false then throw out the exception.msg - the error message format pattern.args - the error message format arguments.public static void illegalArgumentIf(boolean tester)
Throws out an IllegalArgumentException if tester is true.
tester - when true then throw out the exception.public static void illegalArgumentIfNot(boolean tester)
Throws out an IllegalArgumentException if tester is false.
tester - when false then throw out the exception.public static void illegalArgumentIf(boolean tester,
String msg)
Throws out an IllegalArgumentException if tester is false.
tester - when false then throw out the exception.public static void illegalArgumentIfNot(boolean tester,
String msg)
Throws out an IllegalArgumentException if tester is true.
tester - when true then throw out the exception.msg - the error message.public static void illegalArgumentIf(boolean tester,
String msg,
Object... args)
Throws out an IllegalArgumentException with error message specified if tester is true.
tester - when true then throw out the exception.msg - the error message format pattern.args - the error message format arguments.public static void illegalArgumentIfNot(boolean tester,
String msg,
Object... args)
Throws out an IllegalArgumentException with error message specified if tester is false.
tester - when false then throw out the exception.msg - the error message format pattern.args - the error message format arguments.public static void illegalStateIf(boolean tester)
Throws out an IllegalStateException if tester is true.
tester - when true then throw out the exception.public static void illegalStateIfNot(boolean tester)
Throws out an IllegalStateException if tester is false.
tester - when false then throw out the exception.public static void illegalStateIf(boolean tester,
String msg)
Throws out an IllegalStateException with error message specified if tester is true.
tester - when true then throw out the exception.msg - the error message.public static void illegalStateIfNot(boolean tester,
String msg)
Throws out an IllegalStateException with error message specified if tester is false.
tester - when false then throw out the exception.msg - the error message.public static void illegalStateIf(boolean tester,
String msg,
Object... args)
Throws out an IllegalStateException with error message specified if tester is true.
tester - when true then throw out the exception.msg - the error message format pattern.args - the error message format arguments.public static void illegalStateIfNot(boolean tester,
String msg,
Object... args)
Throws out an IllegalStateException with error message specified if tester is false.
tester - when false then throw out the exception.msg - the error message format pattern.args - the error message format arguments.public static RuntimeException asRuntimeException(Exception e)
Convert an Exception to RuntimeException
e - the Exception instanceCopyright © 2014–2019 OSGL (Open Source General Library). All rights reserved.