@@ -624,6 +624,7 @@ public JsonSerializer<Object> findValueSerializer(JavaType valueType)
624
624
* and method(s) called: this method should only be called when caller is
625
625
* certain that this is the primary property value serializer.
626
626
*
627
+ * @param valueType Type of values to serialize
627
628
* @param property Property that is being handled; will never be null, and its
628
629
* type has to match <code>valueType</code> parameter.
629
630
*
@@ -652,6 +653,8 @@ public JsonSerializer<Object> findPrimaryPropertySerializer(JavaType valueType,
652
653
}
653
654
654
655
/**
656
+ * See {@link #findPrimaryPropertySerializer(JavaType, BeanProperty)}
657
+ *
655
658
* @since 2.3
656
659
*/
657
660
@ SuppressWarnings ("unchecked" )
@@ -678,7 +681,79 @@ public JsonSerializer<Object> findPrimaryPropertySerializer(Class<?> valueType,
678
681
}
679
682
return (JsonSerializer <Object >) handlePrimaryContextualization (ser , property );
680
683
}
681
-
684
+
685
+ /**
686
+ * Alternative to {@link #findPrimaryPropertySerializer(JavaType, BeanProperty)} called not
687
+ * for primary value, but "content" of such primary serializer: element of an array or
688
+ * {@link java.util.Collection}, value of {@link java.util.Map} entry and so on.
689
+ * This means that {@code property} passed (if any) does NOT represent value for which
690
+ * serializer is requested but its secondary type (or secondary type of that type,
691
+ * recursively).
692
+ *<p>
693
+ * Serializer returned SHOULD NOT handle type information; caller will (have to) add
694
+ * suitable wrapping if necessary.
695
+ *<p>
696
+ * Note: this call will also contextualize serializer (call {@code createContextual()}
697
+ * before returning it, if applicable (implements {@code ContextualSerializer})
698
+ *
699
+ * @param valueType Type of values to serialize
700
+ * @param property Property that indirectly refers to value being serialized (optional,
701
+ * may be {@code null} for root level serializers)
702
+ *
703
+ * @since 2.11
704
+ */
705
+ @ SuppressWarnings ("unchecked" )
706
+ public JsonSerializer <Object > findContentValueSerializer (JavaType valueType , BeanProperty property )
707
+ throws JsonMappingException
708
+ {
709
+ JsonSerializer <Object > ser = _knownSerializers .untypedValueSerializer (valueType );
710
+ if (ser == null ) {
711
+ ser = _serializerCache .untypedValueSerializer (valueType );
712
+ if (ser == null ) {
713
+ ser = _createAndCacheUntypedSerializer (valueType );
714
+ if (ser == null ) {
715
+ ser = getUnknownTypeSerializer (valueType .getRawClass ());
716
+ // Should this be added to lookups?
717
+ if (CACHE_UNKNOWN_MAPPINGS ) {
718
+ _serializerCache .addAndResolveNonTypedSerializer (valueType , ser , this );
719
+ }
720
+ return ser ;
721
+ }
722
+ }
723
+ }
724
+ return (JsonSerializer <Object >) handleSecondaryContextualization (ser , property );
725
+ }
726
+
727
+ /**
728
+ * See {@link #findContentValueSerializer(JavaType, BeanProperty)}.
729
+ *
730
+ * @since 2.11
731
+ */
732
+ @ SuppressWarnings ("unchecked" )
733
+ public JsonSerializer <Object > findContentValueSerializer (Class <?> valueType ,
734
+ BeanProperty property )
735
+ throws JsonMappingException
736
+ {
737
+ JsonSerializer <Object > ser = _knownSerializers .untypedValueSerializer (valueType );
738
+ if (ser == null ) {
739
+ ser = _serializerCache .untypedValueSerializer (valueType );
740
+ if (ser == null ) {
741
+ ser = _serializerCache .untypedValueSerializer (_config .constructType (valueType ));
742
+ if (ser == null ) {
743
+ ser = _createAndCacheUntypedSerializer (valueType );
744
+ if (ser == null ) {
745
+ ser = getUnknownTypeSerializer (valueType );
746
+ if (CACHE_UNKNOWN_MAPPINGS ) {
747
+ _serializerCache .addAndResolveNonTypedSerializer (valueType , ser , this );
748
+ }
749
+ return ser ;
750
+ }
751
+ }
752
+ }
753
+ }
754
+ return (JsonSerializer <Object >) handleSecondaryContextualization (ser , property );
755
+ }
756
+
682
757
/**
683
758
* Method called to locate regular serializer, matching type serializer,
684
759
* and if both found, wrap them in a serializer that calls both in correct
@@ -1383,10 +1458,10 @@ protected JsonSerializer<Object> _createUntypedSerializer(JavaType type)
1383
1458
// versions, likely due to concurrency fixes for `AnnotatedClass` introspection.
1384
1459
// This sync block could probably be removed; but to minimize any risk of
1385
1460
// regression sync block will only be removed from 3.0.
1386
- synchronized ( _serializerCache ) {
1387
- // 17-Feb-2013, tatu: Used to call deprecated method (that passed property)
1461
+ // 23-Oct-2019, tatu: Due to continuation of 2.x line, removed from 2.11
1462
+ // synchronized (_serializerCache) {
1388
1463
return (JsonSerializer <Object >)_serializerFactory .createSerializer (this , type );
1389
- }
1464
+ // }
1390
1465
}
1391
1466
1392
1467
/**
0 commit comments