@@ -91,6 +91,11 @@ public class POJOPropertiesCollector
91
91
92
92
protected List <POJOPropertyBuilder > _creatorProperties ;
93
93
94
+ /**
95
+ * @since 2.18
96
+ */
97
+ protected PotentialCreators _potentialCreators ;
98
+
94
99
/**
95
100
* A set of "field renamings" that have been discovered, indicating
96
101
* intended renaming of other accessors: key is the implicit original
@@ -218,6 +223,14 @@ public List<BeanPropertyDefinition> getProperties() {
218
223
return new ArrayList <>(props .values ());
219
224
}
220
225
226
+ // @since 2.18
227
+ public PotentialCreators getPotentialCreators () {
228
+ if (!_collected ) {
229
+ collectAll ();
230
+ }
231
+ return _potentialCreators ;
232
+ }
233
+
221
234
public Map <Object , AnnotatedMember > getInjectables () {
222
235
if (!_collected ) {
223
236
collectAll ();
@@ -626,6 +639,8 @@ protected void _addFields(Map<String, POJOPropertyBuilder> props)
626
639
// Completely rewritten in 2.18
627
640
protected void _addCreators (Map <String , POJOPropertyBuilder > props )
628
641
{
642
+ final PotentialCreators creators = new PotentialCreators ();
643
+ _potentialCreators = creators ;
629
644
_creatorProperties = new ArrayList <>();
630
645
631
646
// First, resolve explicit annotations for all potential Creators
@@ -648,35 +663,35 @@ protected void _addCreators(Map<String, POJOPropertyBuilder> props)
648
663
_removeDisabledCreators (constructors );
649
664
_removeDisabledCreators (factories );
650
665
651
- final PotentialCreators collector = new PotentialCreators ();
652
666
// and use annotations to find explicitly chosen Creators
653
667
if (_useAnnotations ) { // can't have explicit ones without Annotation introspection
654
668
// Start with Constructors as they have higher precedence:
655
- _addExplicitlyAnnotatedCreators (collector , constructors , props , false );
669
+ _addExplicitlyAnnotatedCreators (creators , constructors , props , false );
656
670
// followed by Factory methods (lower precedence)
657
- _addExplicitlyAnnotatedCreators (collector , factories , props ,
658
- collector .hasPropertiesBased ());
671
+ _addExplicitlyAnnotatedCreators (creators , factories , props ,
672
+ creators .hasPropertiesBased ());
659
673
}
660
674
661
675
// If no Explicitly annotated creators found, look
662
676
// for ones with explicitly-named ({@code @JsonProperty}) parameters
663
- if (!collector .hasPropertiesBased ()) {
677
+ if (!creators .hasPropertiesBased ()) {
664
678
// only discover constructor Creators?
665
- _addCreatorsWithAnnotatedNames (collector , constructors );
679
+ _addCreatorsWithAnnotatedNames (creators , constructors );
666
680
}
667
681
668
682
// But if no annotation-based Creators found, find/use canonical Creator
669
683
// (JDK 17 Record/Scala/Kotlin)
670
- if (!collector .hasPropertiesBased ()) {
684
+ if (!creators .hasPropertiesBased ()) {
671
685
// for Records:
672
686
if ((canonical != null ) && constructors .contains (canonical )) {
673
687
constructors .remove (canonical );
674
- collector .addPropertiesBased (_config , canonical , "canonical" );
688
+ creators .addPropertiesBased (_config , canonical , "canonical" );
675
689
}
676
690
}
677
691
678
- // And finally add logical properties:
679
- PotentialCreator primary = collector .propertiesBased ;
692
+ // And finally add logical properties for the One Properties-based
693
+ // creator selected (if any):
694
+ PotentialCreator primary = creators .propertiesBased ;
680
695
if (primary != null ) {
681
696
_addCreatorParams (props , primary );
682
697
}
0 commit comments