Class InstantiatorFactory

java.lang.Object
nl.jqno.equalsverifier.internal.instantiators.InstantiatorFactory

public final class InstantiatorFactory extends Object
  • Constructor Details

    • InstantiatorFactory

      private InstantiatorFactory()
  • Method Details

    • of

      public static <T> Instantiator<T> of(ClassProbe<T> probe, org.objenesis.Objenesis objenesis, boolean forceFinalMeansFinal)
      Factory method for obtaining an appropriate Instantiator for the class given via the ClassProbe parameter. Note that the given class is the class that will be instantiated. No subclass will be substituted if the given class is abstract or an interface.
      Type Parameters:
      T - Represents the type of the class to instantiate.
      Parameters:
      probe - Represents the class to instantiate.
      objenesis - To instantiate non-record classes.
      forceFinalMeansFinal - Force "final means final" (JEP 500) mode.
      Returns:
      an InstanceCreator for the given class.
    • of

      public static <T> Instantiator<T> of(ClassProbe<T> probe, InstanceFactory<T> factory, org.objenesis.Objenesis objenesis, boolean forceFinalMeansFinal, boolean throwOnUnknown)
      Factory method for obtaining an appropriate Instantiator for the class given via the ClassProbe parameter. Note that the given class is the class that will be instantiated. No subclass will be substituted if the given class is abstract or an interface.
      Type Parameters:
      T - Represents the type of the class to instantiate.
      Parameters:
      probe - Represents the class to instantiate. Can be null if a factory is provided.
      factory - A factory that can create instances of T. Can be null if a probe is provided.
      objenesis - To instantiate non-record classes.
      forceFinalMeansFinal - Force "final means final" (JEP 500) mode.
      throwOnUnknown - Throw when `factory` asks for a field that doesn't exist in the type. This is useful for copying into subclasses, where the subclass may hold fields unknown in the super.
      Returns:
      an InstanceCreator for the given class.
    • cantReflectivelyModifyFinal

      private static boolean cantReflectivelyModifyFinal()
    • hasFinalFields

      private static <T> boolean hasFinalFields(Class<T> type)
    • findConstructorMatchingFields

      private static <T> Constructor<T> findConstructorMatchingFields(ClassProbe<T> probe)
    • failure

      private static RuntimeException failure(ClassProbe<?> probe)