java.lang.Object
org.eclipse.yasson.internal.ComponentMatcher
Searches for a registered components or Serializer for a given type.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
Flag for searching for generic serializers and adapters in runtime.private final JsonbContext
private final ConcurrentMap
<Type, ComponentBindings> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addAdapter
(Type bindingType, AdapterBinding adapter) private void
addDeserializer
(Type bindingType, DeserializerBinding<?> deserializer) private void
addSerializer
(Type bindingType, SerializerBinding<?> serializer) private ComponentBindings
getBindingInfo
(Type type) getDeserializeAdapterBinding
(Type propertyRuntimeType, ComponentBoundCustomization customization) Get components from property model (if declared by annotation and runtime type matches), or return components searched by runtime type.getDeserializerBinding
(Type propertyRuntimeType, ComponentBoundCustomization customization) Lookup deserializer binding for a given property runtime type.private <T> Optional
<T> getMatchingBinding
(Type runtimeType, ComponentBindings binding, Function<ComponentBindings, T> supplier) getSerializeAdapterBinding
(Type propertyRuntimeType, ComponentBoundCustomization customization) Get components from property model (if declared by annotation and runtime type matches), or return components searched by runtime type.getSerializerBinding
(Type propertyRuntimeType, ComponentBoundCustomization customization) Lookup serializer binding for a given property runtime type.(package private) void
init()
Called during context creation, introspecting user components provided with JsonbConfig.(package private) AdapterBinding
introspectAdapterBinding
(Class<? extends jakarta.json.bind.adapter.JsonbAdapter> adapterClass, jakarta.json.bind.adapter.JsonbAdapter instance) Introspect components generic information and put resolved types into metadata wrapper.(package private) DeserializerBinding
introspectDeserializerBinding
(Class<? extends jakarta.json.bind.serializer.JsonbDeserializer> deserializerClass, jakarta.json.bind.serializer.JsonbDeserializer instance) If an instance of deserializerClass is present in context and is bound for same type, return that instance.(package private) SerializerBinding
introspectSerializerBinding
(Class<? extends jakarta.json.bind.serializer.JsonbSerializer> serializerClass, jakarta.json.bind.serializer.JsonbSerializer instance) If an instance of serializerClass is present in context and is bound for same type, return that instance.private boolean
private boolean
matchTypeArguments
(ParameterizedType requiredType, ParameterizedType componentBound) If runtimeType to adapt is a ParametrizedType, check all type args to match against components args.private void
registerGeneric
(Type bindingType) If type is not parametrized runtime component resolution doesn't has to happen.private Type
resolveTypeArg
(Type adapterTypeArg, Type adapterType) private <T extends AbstractComponentBinding>
Optional<T> searchComponentBinding
(Type runtimeType, Function<ComponentBindings, T> supplier)
-
Field Details
-
jsonbContext
-
genericComponents
private volatile boolean genericComponentsFlag for searching for generic serializers and adapters in runtime. -
userComponents
-
-
Constructor Details
-
ComponentMatcher
ComponentMatcher(JsonbContext context) Create component matcher.- Parameters:
context
- mandatory
-
-
Method Details
-
init
void init()Called during context creation, introspecting user components provided with JsonbConfig. -
getBindingInfo
-
addSerializer
-
addDeserializer
-
addAdapter
-
registerGeneric
If type is not parametrized runtime component resolution doesn't has to happen.- Parameters:
bindingType
- component binding type
-
getSerializerBinding
public Optional<SerializerBinding<?>> getSerializerBinding(Type propertyRuntimeType, ComponentBoundCustomization customization) Lookup serializer binding for a given property runtime type.- Parameters:
propertyRuntimeType
- runtime type of a propertycustomization
- with component info- Returns:
- serializer optional
-
getDeserializerBinding
public Optional<DeserializerBinding<?>> getDeserializerBinding(Type propertyRuntimeType, ComponentBoundCustomization customization) Lookup deserializer binding for a given property runtime type.- Parameters:
propertyRuntimeType
- runtime type of a propertycustomization
- customization with component info- Returns:
- serializer optional
-
getSerializeAdapterBinding
public Optional<AdapterBinding> getSerializeAdapterBinding(Type propertyRuntimeType, ComponentBoundCustomization customization) Get components from property model (if declared by annotation and runtime type matches), or return components searched by runtime type.- Parameters:
propertyRuntimeType
- runtime type not nullcustomization
- customization with component info- Returns:
- components info if present
-
getDeserializeAdapterBinding
public Optional<AdapterBinding> getDeserializeAdapterBinding(Type propertyRuntimeType, ComponentBoundCustomization customization) Get components from property model (if declared by annotation and runtime type matches), or return components searched by runtime type.- Parameters:
propertyRuntimeType
- runtime type not nullcustomization
- customization with component info- Returns:
- components info if present
-
searchComponentBinding
private <T extends AbstractComponentBinding> Optional<T> searchComponentBinding(Type runtimeType, Function<ComponentBindings, T> supplier) -
getMatchingBinding
private <T> Optional<T> getMatchingBinding(Type runtimeType, ComponentBindings binding, Function<ComponentBindings, T> supplier) -
matches
-
matchTypeArguments
private boolean matchTypeArguments(ParameterizedType requiredType, ParameterizedType componentBound) If runtimeType to adapt is a ParametrizedType, check all type args to match against components args. -
introspectAdapterBinding
AdapterBinding introspectAdapterBinding(Class<? extends jakarta.json.bind.adapter.JsonbAdapter> adapterClass, jakarta.json.bind.adapter.JsonbAdapter instance) Introspect components generic information and put resolved types into metadata wrapper.- Parameters:
adapterClass
- class of an componentsinstance
- components instance- Returns:
- introspected info with resolved typevar types.
-
introspectDeserializerBinding
DeserializerBinding introspectDeserializerBinding(Class<? extends jakarta.json.bind.serializer.JsonbDeserializer> deserializerClass, jakarta.json.bind.serializer.JsonbDeserializer instance) If an instance of deserializerClass is present in context and is bound for same type, return that instance. Otherwise create new instance and set it to context.- Parameters:
deserializerClass
- class of deserializerinstance
- instance to use if not cached already- Returns:
- wrapper used in property models
-
introspectSerializerBinding
SerializerBinding introspectSerializerBinding(Class<? extends jakarta.json.bind.serializer.JsonbSerializer> serializerClass, jakarta.json.bind.serializer.JsonbSerializer instance) If an instance of serializerClass is present in context and is bound for same type, return that instance. Otherwise create new instance and set it to context.- Parameters:
serializerClass
- class of deserializerinstance
- instance to use if not cached- Returns:
- wrapper used in property models
-
resolveTypeArg
-