Class ProvidedFactoryInstantiator<T>

java.lang.Object
nl.jqno.equalsverifier.internal.instantiators.ProvidedFactoryInstantiator<T>
All Implemented Interfaces:
Instantiator<T>

public final class ProvidedFactoryInstantiator<T> extends Object implements Instantiator<T>
Creates an instance of a class using a factory provided by the user.
  • Field Details

    • instanceFactory

      private final InstanceFactory<? extends T> instanceFactory
    • throwing

      private final boolean throwing
  • Constructor Details

    • ProvidedFactoryInstantiator

      ProvidedFactoryInstantiator(InstanceFactory<? extends T> instanceFactory, boolean throwing)
      Package private constructor. Use InstantiatorFactory.of(ClassProbe, Objenesis, boolean) instead.
      Parameters:
      instanceFactory - The factory to use.
      throwing - Whether or not to throw an exception when the factory asks for an unknown field.
  • Method Details

    • instantiate

      public T instantiate(Map<Field,Object> values)
      Creates an instance of the given type, with its field set to the given values. If no value is given for a specific field, the field will be set to its default value: null for object references, 0 for numbers, false for booleans.
      Specified by:
      instantiate in interface Instantiator<T>
      Parameters:
      values - Values to assign to the instance's fields.
      Returns:
      An instance with assigned values.