Interface FieldDiscoverer<I>
- Type Parameters:
I
- intermediate data type
Any type of data object can be added this way.
- Since:
- 4.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
A collector for the necessary metadata for fields.static interface
A handler that controls the deserialization process for an object.static interface
A handler for working with mutable objects in the object mapper. -
Method Summary
Modifier and TypeMethodDescription<V> @Nullable FieldDiscoverer.InstanceFactory<I>
discover
(AnnotatedType target, FieldDiscoverer.FieldCollector<I, V> collector) Inspect thetarget
type for fields to be supplied to thecollector
.static FieldDiscoverer<?>
Create a new discoverer for object instance fields.static FieldDiscoverer<?>
instantiableObject
(CheckedFunction<AnnotatedType, @Nullable Supplier<Object>, SerializationException> instanceFactory) Create a new discoverer for object instance fields.static FieldDiscoverer<?>
object
(CheckedFunction<AnnotatedType, @Nullable Supplier<Object>, SerializationException> instanceFactory) Create a new discoverer for object instance fields.static FieldDiscoverer<?>
object
(CheckedFunction<AnnotatedType, @Nullable Supplier<Object>, SerializationException> instanceFactory, String instanceUnavailableErrorMessage) Create a new discoverer for object instance fields.static FieldDiscoverer<?>
record()
Create a new field discoverer that will handle record classes.
-
Method Details
-
record
Create a new field discoverer that will handle record classes.This discoverer will use the record's canonical constructor to create new instances, passing
null
for any missing parameters. The accessor methods for each record component will be used to read values from the record.- Returns:
- new discoverer
- Since:
- 4.0.0
-
object
static FieldDiscoverer<?> object(CheckedFunction<AnnotatedType, @Nullable Supplier<Object>, SerializationException> instanceFactory) Create a new discoverer for object instance fields.This discoverer will process any non-static and non-transient field in the object. Modifying
final
fields is unsupported and may stop working with newer Java versions.- Parameters:
instanceFactory
- a factory for instance providers- Returns:
- new discoverer
- Since:
- 4.0.0
-
object
static FieldDiscoverer<?> object(CheckedFunction<AnnotatedType, @Nullable Supplier<Object>, SerializationException> instanceFactory, String instanceUnavailableErrorMessage) Create a new discoverer for object instance fields.This discoverer will process any non-static and non-transient field in the object. Modifying
final
fields is unsupported and may stop working with newer Java versions.- Parameters:
instanceFactory
- a factory for instance providersinstanceUnavailableErrorMessage
- a message that will be part of the exception thrown when trying to create instances for an unsupported type- Returns:
- new discoverer
- Since:
- 4.1.0
-
instantiableObject
static FieldDiscoverer<?> instantiableObject(CheckedFunction<AnnotatedType, @Nullable Supplier<Object>, SerializationException> instanceFactory) Create a new discoverer for object instance fields.This discoverer will process any non-static and non-transient field in the object. Modifying
final
fields is unsupported and may stop working with newer Java versions.This discoverer will only match objects that it can create an instance of (i. e. where
instanceFactory
returns a non-null
supplier).- Parameters:
instanceFactory
- a factory for instance providers- Returns:
- new discoverer
- Since:
- 4.2.0
-
emptyConstructorObject
Create a new discoverer for object instance fields.Only objects with empty constructors can be created.
- Returns:
- new discoverer
- Since:
- 4.0.0
- See Also:
-
discover
<V> @Nullable FieldDiscoverer.InstanceFactory<I> discover(AnnotatedType target, FieldDiscoverer.FieldCollector<I, V> collector) throws SerializationExceptionInspect thetarget
type for fields to be supplied to thecollector
.If the target type is handleable, a non-null value must be returned. Fields can only be collected from one source at the moment, so if the instance factory is null any discovered fields will be discarded.
- Type Parameters:
V
- object type- Parameters:
target
- type to inspectcollector
- collector for discovered fields.- Returns:
- a factory for handling the construction of object instances, or
null
iftarget
is not of a handleable type. - Throws:
SerializationException
- if any fields have invalid data- Since:
- 4.0.0
-