Module nl.jqno.equalsverifier
Class ReflectionInstantiator<T>
java.lang.Object
nl.jqno.equalsverifier.internal.instantiators.ReflectionInstantiator<T>
- All Implemented Interfaces:
Instantiator<T>
Creates an instance of a class using reflection on potentially final fields.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.objenesis.instantiator.ObjectInstantiator<T> private final ClassProbe<T> -
Constructor Summary
ConstructorsConstructorDescriptionReflectionInstantiator(ClassProbe<T> probe, org.objenesis.Objenesis objenesis) Package private constructor. -
Method Summary
Modifier and TypeMethodDescriptioninstantiate(Map<Field, Object> values) Creates an instance of the given type, with its field set to the given values.private voidtraverseFields(Map<Field, Object> values, BiConsumer<FieldProbe, Object> setValue) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface nl.jqno.equalsverifier.internal.instantiators.Instantiator
copy
-
Field Details
-
type
-
probe
-
objenesisInstantiator
-
-
Constructor Details
-
ReflectionInstantiator
ReflectionInstantiator(ClassProbe<T> probe, org.objenesis.Objenesis objenesis) Package private constructor. UseInstantiatorFactory.of(ClassProbe, Objenesis, boolean)instead.- Parameters:
probe- The ClassProbe for the type.objenesis- The Objenesis instance to use.
-
-
Method Details
-
instantiate
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:
instantiatein interfaceInstantiator<T>- Parameters:
values- Values to assign to the instance's fields.- Returns:
- An instance with assigned values.
-
traverseFields
-