Module nl.jqno.equalsverifier
Class InstantiatorFactory
java.lang.Object
nl.jqno.equalsverifier.internal.instantiators.InstantiatorFactory
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanprivate static RuntimeExceptionfailure(ClassProbe<?> probe) private static <T> Constructor<T> findConstructorMatchingFields(ClassProbe<T> probe) private static <T> booleanhasFinalFields(Class<T> type) 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.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.
-
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
InstanceCreatorfor 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 ofT. 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
InstanceCreatorfor the given class.
-
cantReflectivelyModifyFinal
private static boolean cantReflectivelyModifyFinal() -
hasFinalFields
-
findConstructorMatchingFields
-
failure
-