Package com.pnfsoftware.jeb.util.base
Class Assert
java.lang.Object
com.pnfsoftware.jeb.util.base.Assert
A replacement for built-in
asserts. Production-compatible assert-likes. Do not throw
AssertionError on failure; instead, a RuntimeException is raised.
Assert methods throw RuntimeException. The stacktrace of such an exception is adjusted to
reflect the actual code line where a(...) or fail(...) was called.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voida(boolean expression) Assert that a condition is true.static voidAssert that a condition is true.static voidAssert that a condition is true.static voidFail ONLY on debug builds.static voidFail ONLY on debug builds.static voidFail only on debug builds by throwing the provided throwable, or logging it on release builds.static voidfail()Unconditionally fail.static voidUnconditionally fail.
-
Constructor Details
-
Assert
public Assert()
-
-
Method Details
-
a
Assert that a condition is true.- Parameters:
expression- condition to verifymessage- optional failure message
-
a
Assert that a condition is true.- Parameters:
expression- condition to verifymessage- optional failure message formatargs- optional message format arguments
-
a
public static void a(boolean expression) Assert that a condition is true.- Parameters:
expression- condition to verify
-
fail
Unconditionally fail.- Parameters:
message- optional failure message
-
fail
public static void fail()Unconditionally fail. -
debugFail
Fail ONLY on debug builds. Use carefully; this method can yield side-effect bugs on release builds that would have otherwise be caught in debug mode.- Parameters:
message- optional failure message
-
debugFail
public static void debugFail()Fail ONLY on debug builds. Use carefully; this method can yield side-effect bugs on release builds that would have otherwise be caught in debug mode. -
debugFail
Fail only on debug builds by throwing the provided throwable, or logging it on release builds.- Parameters:
t- throwable to report
-