Class EqualsVerifierReport

java.lang.Object
nl.jqno.equalsverifier.EqualsVerifierReport

public final class EqualsVerifierReport extends Object
Contains the results of an EqualsVerifier run.

When the run was successful, should contain an empty message and a null cause. When the run was unsuccessful, the message is identical to the message of the exception that SingleTypeEqualsVerifierApi.verify() would throw, and the cause would be identical to its cause.

Since:
3.0
  • Field Details

    • type

      private final Class<?> type
    • successful

      private final boolean successful
    • message

      private final String message
    • cause

      private final Throwable cause
  • Constructor Details

  • Method Details

    • success

      public static EqualsVerifierReport success(Class<?> type)
      Factory method for a successful run of EqualsVerifier.
      Parameters:
      type - The class that was tested.
      Returns:
      an EqualsVerifierReport representing the successful result of a run of EqualsVerifier.
      Since:
      3.2
    • failure

      public static EqualsVerifierReport failure(Class<?> type, String message, Throwable cause)
      Factory method for an unsuccessful run of EqualsVerifier.
      Parameters:
      type - The class that was tested.
      message - Error message when the run is unsuccessful.
      cause - Exception when the run is unsuccessful.
      Returns:
      an EqualsVerifierReport representing the failed result of a run of EqualsVerifier.
      Since:
      3.2
    • getType

      public Class<?> getType()
      Returns the class that was tested.
      Returns:
      the class that was tested.
      Since:
      3.2
    • isSuccessful

      public boolean isSuccessful()
      Returns whether the tested class conforms to the equals() and hashCode() contracts.
      Returns:
      whether the class tested by SingleTypeEqualsVerifierApi.report() conforms to the Object.equals(Object) and Object.hashCode() contracts.
      Since:
      3.0
    • getMessage

      public String getMessage()
      Returns a detailed error message if the tested class does not conform to the equals() and hashCode() contracts.
      Returns:
      a detailed error message if the class tested by SingleTypeEqualsVerifierApi.report() does not conform to the Object.equals(Object) and Object.hashCode() contracts; or an empty string if it does.
      Since:
      3.0
    • getCause

      public Throwable getCause()
      Returns the exception that detected the failure of the tested class to conform to the equals() and hashCode() contracts.
      Returns:
      an exception indicating the source of the failure if the class tested by SingleTypeEqualsVerifierApi.report() does not conform to the Object.equals(Object) and Object.hashCode() contracts; or null if it does.
      Since:
      3.0