Interface EqualsVerifierApi<T>

Type Parameters:
T - The class under test.
All Known Implementing Classes:
ConfiguredEqualsVerifier, MultipleTypeEqualsVerifierApi, SingleTypeEqualsVerifierApi

public interface EqualsVerifierApi<T>
Helps to construct an EqualsVerifier test with a fluent API.
Since:
3.2
  • Method Details

    • suppress

      EqualsVerifierApi<T> suppress(Warning... warnings)
      Suppresses warnings given by EqualsVerifier. See Warning to see what warnings can be suppressed.
      Parameters:
      warnings - A list of warnings to suppress in EqualsVerifier.
      Returns:
      this, for easy method chaining.
      Since:
      0.6
    • set

      EqualsVerifierApi<T> set(Mode... modes)
      Sets modes that influence how EqualsVerifier operates.
      Parameters:
      modes - A list of modes to influence how EqualsVerifier operates.
      Returns:
      this, for easy method chaining.
      Since:
      4.0
    • withPrefabValues

      <S> EqualsVerifierApi<T> withPrefabValues(Class<S> otherType, S red, S blue)
      Adds prefabricated values for instance fields of classes that EqualsVerifier cannot instantiate by itself. This overload will attempt to copy red. If that fails, use the other overload.
      Type Parameters:
      S - The class of the prefabricated values.
      Parameters:
      otherType - The class of the prefabricated values.
      red - An instance of S.
      blue - Another instance of S, not equal to red.
      Returns:
      this, for easy method chaining.
      Throws:
      NullPointerException - If either otherType, red, or blue is null.
      IllegalArgumentException - If red equals blue.
      Since:
      0.2
    • withPrefabValues

      <S> EqualsVerifierApi<T> withPrefabValues(Class<S> otherType, S red, S blue, S redCopy)
      Adds prefabricated values for instance fields of classes that EqualsVerifier cannot instantiate by itself.
      Type Parameters:
      S - The class of the prefabricated values.
      Parameters:
      otherType - The class of the prefabricated values.
      red - An instance of S.
      blue - Another instance of S, not equal to red.
      redCopy - A copy of red.
      Returns:
      this, for easy method chaining.
      Throws:
      NullPointerException - If either otherType, red, or blue is null.
      IllegalArgumentException - If red equals blue.
      Since:
      4.4
    • withResettablePrefabValues

      <S> EqualsVerifierApi<T> withResettablePrefabValues(Class<S> otherType, Supplier<S> red, Supplier<S> blue)
      Adds Suppliers for resettable prefabricated values for instance fields of classes that EqualsVerifier cannot instantiate by itself. Resettable values are values that are created new every time a new instance of T is constructed within EqualsVerifier. This can be useful when T mutates its instances of S.
      Type Parameters:
      S - The class of the prefabricated values.
      Parameters:
      otherType - The class of the prefabricated values.
      red - An instance of S.
      blue - Another instance of S, not equal to red.
      Returns:
      this, for easy method chaining.
      Throws:
      NullPointerException - If either otherType, red, or blue is null.
      IllegalArgumentException - If red equals blue.
      Since:
      4.1
    • withGenericPrefabValues

      <S> EqualsVerifierApi<T> withGenericPrefabValues(Class<S> otherType, Func.Func1<?,S> factory)
      Adds a factory to generate prefabricated values for instance fields of classes with 1 generic type parameter that EqualsVerifier cannot instantiate by itself.
      Type Parameters:
      S - The class of the prefabricated values.
      Parameters:
      otherType - The class of the prefabricated values.
      factory - A factory to generate an instance of S, given a value of its generic type parameter.
      Returns:
      this, for easy method chaining.
      Throws:
      NullPointerException - if either otherType or factory is null.
      Since:
      3.0
    • withGenericPrefabValues

      <S> EqualsVerifierApi<T> withGenericPrefabValues(Class<S> otherType, Func.Func2<?,?,S> factory)
      Adds a factory to generate prefabricated values for instance fields of classes with 2 generic type parameters that EqualsVerifier cannot instantiate by itself.
      Type Parameters:
      S - The class of the prefabricated values.
      Parameters:
      otherType - The class of the prefabricated values.
      factory - A factory to generate an instance of S, given a value of each of its generic type parameters.
      Returns:
      this, for easy method chaining.
      Throws:
      NullPointerException - if either otherType or factory is null.
      Since:
      3.0
    • usingGetClass

      EqualsVerifierApi<T> usingGetClass()
      Signals that getClass is used in the implementation of the equals method, instead of an instanceof check.
      Returns:
      this, for easy method chaining.
      Since:
      0.7
      See Also:
    • withFieldnameToGetterConverter

      EqualsVerifierApi<T> withFieldnameToGetterConverter(Function<String,String> converter)
      Determines how a getter name can be derived from a field name. The default behavior is to uppercase the field's first letter and prepend 'get'. For instance, a field name 'employee' would correspond to getter name 'getEmployee'. This method can be used if your project has a different naming convention.
      Parameters:
      converter - A function that converts from field name to getter name.
      Returns:
      this, for easy method chaining.
      Since:
      3.15