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 Type
    Method
    Description
    default void
    assertFalse(boolean v1)
    Asserts that the value must be false, throws an exception if the assertion is true
    default void
    assertFalse(boolean v1, String msg)
    Asserts that the value must be false, throws an exception if the assertion is true
    default void
    Asserted value cannot be null; throws an exception if it is null
    default void
    Asserted value cannot be null; throws an exception if it is null
    default void
    Throws an exception if the asserted value is null
    default void
    Asserts that the assertion value is null, otherwise throws an exception
    default void
    assertTrue(boolean v1)
    Asserts that the value must be true, throws an exception if the assertion is false
    default void
    assertTrue(boolean v1, String msg)
    Asserts that the value must be true, throws an exception if the assertion is false
    default void
    assertTrueThrows(boolean v1)
    Throws an exception if the asserted value is true
    default void
    assertTrueThrows(boolean v1, String msg)
    Throws an exception if the asserted value is true
    int
    Return the numeric error code.
    Return the human-readable error message.
    default <T> @NonNull T
    require(T value)
    Parameter cannot be null; throws an exception if the parameter is null
  • Method Details

    • getMessage

      String getMessage()
      Return the human-readable error message.
      Returns:
      the error message
    • getCode

      int getCode()
      Return the numeric error code.
      Returns:
      the error code
    • assertTrueThrows

      default void assertTrueThrows(boolean v1) throws MessageException
      Throws an exception if the asserted value is true
      Parameters:
      v1 - The assertion value
      Throws:
      MessageException - e
    • assertTrueThrows

      default void assertTrueThrows(boolean v1, String msg) throws MessageException
      Throws an exception if the asserted value is true
      Parameters:
      v1 - The assertion value
      msg - Custom message
      Throws:
      MessageException - e
    • assertNonNull

      default void assertNonNull(Object value, String msg) throws MessageException
      Asserted value cannot be null; throws an exception if it is null
      Parameters:
      value - The assertion value
      msg - Custom message
      Throws:
      MessageException - e
    • assertNonNull

      default void assertNonNull(Object value) throws MessageException
      Asserted value cannot be null; throws an exception if it is null
      Parameters:
      value - The assertion value
      Throws:
      MessageException - e
    • assertNullThrows

      default void assertNullThrows(Object value) throws MessageException
      Throws an exception if the asserted value is null
      Parameters:
      value - The assertion value
      Throws:
      MessageException - e
    • assertNullThrows

      default void assertNullThrows(Object value, String msg) throws MessageException
      Asserts that the assertion value is null, otherwise throws an exception
      Parameters:
      value - The assertion value
      msg - Custom message
      Throws:
      MessageException - e
    • assertTrue

      default void assertTrue(boolean v1) throws MessageException
      Asserts that the value must be true, throws an exception if the assertion is false
      Parameters:
      v1 - The assertion value
      Throws:
      MessageException - e
    • assertFalse

      default void assertFalse(boolean v1) throws MessageException
      Asserts that the value must be false, throws an exception if the assertion is true
      Parameters:
      v1 - The assertion value
      Throws:
      MessageException - e
    • assertFalse

      default void assertFalse(boolean v1, String msg) throws MessageException
      Asserts that the value must be false, throws an exception if the assertion is true
      Parameters:
      v1 - The assertion value
      msg - Custom message
      Throws:
      MessageException - e
    • assertTrue

      default void assertTrue(boolean v1, String msg) throws MessageException
      Asserts that the value must be true, throws an exception if the assertion is false
      Parameters:
      v1 - The assertion value
      msg - 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