@@ -520,7 +520,7 @@ protected ValueSerializer<?> buildContainerSerializer(SerializationContext ctxt,
520
520
beanDescRef , formatOverrides , staticTyping ,
521
521
elementTypeSerializer , elementValueSerializer );
522
522
}
523
- // With Map -like, just 2 options: (1) Custom, (2) Annotations
523
+ // With Collection -like, just 2 options: (1) Custom, (2) Annotations
524
524
ValueSerializer <?> ser = null ;
525
525
CollectionLikeType clType = (CollectionLikeType ) type ;
526
526
for (Serializers serializers : customSerializers ()) { // (1) Custom
@@ -574,18 +574,17 @@ protected ValueSerializer<?> buildCollectionSerializer(SerializationContext ctxt
574
574
}
575
575
}
576
576
577
- JsonFormat .Value format = _calculateEffectiveFormat (ctxt ,
578
- beanDescRef , Collection .class , formatOverrides );
579
577
if (ser == null ) {
580
578
ser = findSerializerByAnnotations (ctxt , type , beanDescRef ); // (2) Annotations
581
579
if (ser == null ) {
580
+ JsonFormat .Value format = _calculateEffectiveFormat (ctxt ,
581
+ beanDescRef , Collection .class , formatOverrides );
582
582
// We may also want to use serialize Collections "as beans", if (and only if)
583
583
// shape specified as "POJO"
584
584
if (format .getShape () == JsonFormat .Shape .POJO ) {
585
585
return null ;
586
586
}
587
- Class <?> raw = type .getRawClass ();
588
- if (EnumSet .class .isAssignableFrom (raw )) {
587
+ if (type .isTypeOrSubTypeOf (EnumSet .class )) {
589
588
// this may or may not be available (Class doesn't; type of field/method does)
590
589
JavaType enumType = type .getContentType ();
591
590
// and even if nominally there is something, only use if it really is enum
@@ -595,7 +594,7 @@ protected ValueSerializer<?> buildCollectionSerializer(SerializationContext ctxt
595
594
ser = buildEnumSetSerializer (enumType );
596
595
} else {
597
596
Class <?> elementRaw = type .getContentType ().getRawClass ();
598
- if (isIndexedList (raw )) {
597
+ if (isIndexedList (type . getRawClass () )) {
599
598
if (elementRaw == String .class ) {
600
599
// Only optimize if std implementation, not custom
601
600
if (ClassUtil .isJacksonStdImpl (elementValueSerializer )) {
@@ -667,14 +666,6 @@ protected ValueSerializer<?> buildMapSerializer(SerializationContext ctxt,
667
666
boolean staticTyping , ValueSerializer <Object > keySerializer ,
668
667
TypeSerializer elementTypeSerializer , ValueSerializer <Object > elementValueSerializer )
669
668
{
670
- JsonFormat .Value format = _calculateEffectiveFormat (ctxt ,
671
- beanDescRef , Map .class , formatOverrides );
672
-
673
- // [databind#467]: This is where we could allow serialization "as POJO": But! It's
674
- // nasty to undo, and does not apply on per-property basis. So, hardly optimal
675
- if (format .getShape () == JsonFormat .Shape .POJO ) {
676
- return null ;
677
- }
678
669
ValueSerializer <?> ser = null ;
679
670
680
671
// Order of lookups:
@@ -691,6 +682,15 @@ protected ValueSerializer<?> buildMapSerializer(SerializationContext ctxt,
691
682
if (ser == null ) {
692
683
ser = findSerializerByAnnotations (ctxt , type , beanDescRef ); // (2) Annotations
693
684
if (ser == null ) {
685
+ JsonFormat .Value format = _calculateEffectiveFormat (ctxt ,
686
+ beanDescRef , Map .class , formatOverrides );
687
+
688
+ // [databind#467]: This is where we could allow serialization "as POJO": But! It's
689
+ // nasty to undo, and does not apply on per-property basis. So, hardly optimal
690
+ if (format .getShape () == JsonFormat .Shape .POJO ) {
691
+ return null ;
692
+ }
693
+
694
694
Object filterId = findFilterId (config , beanDescRef );
695
695
// 01-May-2016, tatu: Which base type to use here gets tricky, since
696
696
// most often it ought to be `Map` or `EnumMap`, but due to abstract
@@ -897,9 +897,8 @@ protected ValueSerializer<?> buildArraySerializer(SerializationContext ctxt,
897
897
ValueSerializer <?> ser = null ;
898
898
899
899
for (Serializers serializers : customSerializers ()) { // (1) Custom
900
- ser = serializers .findArraySerializer (config , type , beanDescRef , formatOverrides ,
901
- elementTypeSerializer , elementValueSerializer );
902
- if (ser != null ) {
900
+ if ((ser = serializers .findArraySerializer (config , type , beanDescRef , formatOverrides ,
901
+ elementTypeSerializer , elementValueSerializer )) != null ) {
903
902
break ;
904
903
}
905
904
}
0 commit comments