Class ConfiguredEqualsVerifier

java.lang.Object
nl.jqno.equalsverifier.ConfiguredEqualsVerifier
All Implemented Interfaces:
EqualsVerifierApi<Void>

public final class ConfiguredEqualsVerifier extends Object implements EqualsVerifierApi<Void>
  • Constructor Details

    • ConfiguredEqualsVerifier

      public ConfiguredEqualsVerifier()
      Constructor.
  • Method Details

    • copy

      public ConfiguredEqualsVerifier copy()
      Returns a copy of the configuration.
      Returns:
      a copy of the configuration.
    • suppress

      public ConfiguredEqualsVerifier suppress(Warning... warnings)
      Suppresses warnings given by EqualsVerifier. See Warning to see what warnings can be suppressed.
      Specified by:
      suppress in interface EqualsVerifierApi<Void>
      Parameters:
      warnings - A list of warnings to suppress in EqualsVerifier.
      Returns:
      this, for easy method chaining.
    • withPrefabValues

      public <S> ConfiguredEqualsVerifier withPrefabValues(Class<S> otherType, S red, S blue)
      Adds prefabricated values for instance fields of classes that EqualsVerifier cannot instantiate by itself.
      Specified by:
      withPrefabValues in interface EqualsVerifierApi<Void>
      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.
    • withGenericPrefabValues

      public <S> ConfiguredEqualsVerifier 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.
      Specified by:
      withGenericPrefabValues in interface EqualsVerifierApi<Void>
      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.
    • withGenericPrefabValues

      public <S> ConfiguredEqualsVerifier 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.
      Specified by:
      withGenericPrefabValues in interface EqualsVerifierApi<Void>
      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.
    • usingGetClass

      public ConfiguredEqualsVerifier usingGetClass()
      Signals that getClass is used in the implementation of the equals method, instead of an instanceof check.
      Specified by:
      usingGetClass in interface EqualsVerifierApi<Void>
      Returns:
      this, for easy method chaining.
      See Also:
    • withFieldnameToGetterConverter

      public ConfiguredEqualsVerifier withFieldnameToGetterConverter(Function<String,String> converter)
      Description copied from interface: EqualsVerifierApi
      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.
      Specified by:
      withFieldnameToGetterConverter in interface EqualsVerifierApi<Void>
      Parameters:
      converter - A function that converts from field name to getter name.
      Returns:
      this, for easy method chaining.
    • withResetCaches

      public ConfiguredEqualsVerifier withResetCaches()
      Signals that all internal caches need to be reset. This is useful when the test framework uses multiple ClassLoaders to run tests, causing Class instances that would normally be equal, to be unequal, because their ClassLoaders don't match.
      Specified by:
      withResetCaches in interface EqualsVerifierApi<Void>
      Returns:
      this, for easy method chaining.
    • forClass

      public <T> SingleTypeEqualsVerifierApi<T> forClass(Class<T> type)
      Factory method. For general use.
      Type Parameters:
      T - The type.
      Parameters:
      type - The class for which the equals method should be tested.
      Returns:
      A fluent API for EqualsVerifier.
    • forClasses

      public MultipleTypeEqualsVerifierApi forClasses(Iterable<Class<?>> classes)
      Factory method. For general use.
      Parameters:
      classes - An iterable containing the classes for which equals method should be tested.
      Returns:
      A fluent API for EqualsVerifier.
    • forClasses

      public MultipleTypeEqualsVerifierApi forClasses(Class<?> first, Class<?> second, Class<?>... more)
      Factory method. For general use.
      Parameters:
      first - A class for which the equals method should be tested.
      second - Another class for which the equals method should be tested.
      more - More classes for which the equals method should be tested.
      Returns:
      A fluent API for EqualsVerifier.
    • forPackage

      public MultipleTypeEqualsVerifierApi forPackage(String packageName)
      Factory method. For general use.

      Note that this operation may be slow. If the test is too slow, use forClasses(Class, Class, Class...) instead.

      Parameters:
      packageName - A package for which each class's equals should be tested.
      Returns:
      A fluent API for EqualsVerifier.
    • forPackage

      public MultipleTypeEqualsVerifierApi forPackage(String packageName, boolean scanRecursively)
      Factory method. For general use.

      Note that this operation may be slow. If the test is too slow, use forClasses(Class, Class, Class...) instead.

      Parameters:
      packageName - A package for which each class's equals should be tested.
      scanRecursively - true to scan all sub-packages
      Returns:
      A fluent API for EqualsVerifier.
    • forPackage

      public MultipleTypeEqualsVerifierApi forPackage(String packageName, Class<?> mustExtend)
      Factory method. For general use.

      Note that this operation may be slow. If the test is too slow, use forClasses(Class, Class, Class...) instead.

      Also note that if mustExtend is given, and it exists within packageName, it will NOT be included.

      Parameters:
      packageName - A package for which each class's equals should be tested.
      mustExtend - if not null, returns only classes that extend or implement this class.
      Returns:
      A fluent API for EqualsVerifier.