Interface ErrorInformation
- All Known Implementing Classes:
ActionErrorEnum
public interface ErrorInformation
Contract for error information that can be used to throw
MessageExceptions
with assertion-style convenience methods.
Implementations provide a numeric code and a human-readable
message. The default methods offer a rich set of assertion
helpers that throw MessageException when the condition is not met.
- Author:
- 渔民小镇
- date:
- 2022-01-14
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidassertFalse(boolean v1) Asserts that the value must be false, throws an exception if the assertion is truedefault voidassertFalse(boolean v1, String msg) Asserts that the value must be false, throws an exception if the assertion is truedefault voidassertNonNull(Object value) Asserted value cannot be null; throws an exception if it is nulldefault voidassertNonNull(Object value, String msg) Asserted value cannot be null; throws an exception if it is nulldefault voidassertNullThrows(Object value) Throws an exception if the asserted value is nulldefault voidassertNullThrows(Object value, String msg) Asserts that the assertion value is null, otherwise throws an exceptiondefault voidassertTrue(boolean v1) Asserts that the value must be true, throws an exception if the assertion is falsedefault voidassertTrue(boolean v1, String msg) Asserts that the value must be true, throws an exception if the assertion is falsedefault voidassertTrueThrows(boolean v1) Throws an exception if the asserted value is truedefault voidassertTrueThrows(boolean v1, String msg) Throws an exception if the asserted value is trueintgetCode()Return the numeric error code.Return the human-readable error message.default <T> @NonNull Trequire(T value) Parameter cannot be null; throws an exception if the parameter is null
-
Method Details
-
getMessage
-
getCode
int getCode()Return the numeric error code.- Returns:
- the error code
-
assertTrueThrows
Throws an exception if the asserted value is true- Parameters:
v1- The assertion value- Throws:
MessageException- e
-
assertTrueThrows
Throws an exception if the asserted value is true- Parameters:
v1- The assertion valuemsg- Custom message- Throws:
MessageException- e
-
assertNonNull
Asserted value cannot be null; throws an exception if it is null- Parameters:
value- The assertion valuemsg- Custom message- Throws:
MessageException- e
-
assertNonNull
Asserted value cannot be null; throws an exception if it is null- Parameters:
value- The assertion value- Throws:
MessageException- e
-
assertNullThrows
Throws an exception if the asserted value is null- Parameters:
value- The assertion value- Throws:
MessageException- e
-
assertNullThrows
Asserts that the assertion value is null, otherwise throws an exception- Parameters:
value- The assertion valuemsg- Custom message- Throws:
MessageException- e
-
assertTrue
Asserts that the value must be true, throws an exception if the assertion is false- Parameters:
v1- The assertion value- Throws:
MessageException- e
-
assertFalse
Asserts that the value must be false, throws an exception if the assertion is true- Parameters:
v1- The assertion value- Throws:
MessageException- e
-
assertFalse
Asserts that the value must be false, throws an exception if the assertion is true- Parameters:
v1- The assertion valuemsg- Custom message- Throws:
MessageException- e
-
assertTrue
Asserts that the value must be true, throws an exception if the assertion is false- Parameters:
v1- The assertion valuemsg- Custom message- Throws:
MessageException- e
-
require
default <T> @NonNull T require(T value) Parameter cannot be null; throws an exception if the parameter is null- Type Parameters:
T- T- Parameters:
value- value- Returns:
- T
-