@@ -466,58 +466,70 @@ public AnnotatedMethod getSetter()
466
466
}
467
467
// But if multiple, verify that they do not conflict...
468
468
for (; next != null ; next = next .next ) {
469
- // Allow masking, i.e. do not fail if one is in super-class from the other
470
- Class <?> currClass = curr .value .getDeclaringClass ();
471
- Class <?> nextClass = next .value .getDeclaringClass ();
472
- if (currClass != nextClass ) {
473
- if (currClass .isAssignableFrom (nextClass )) { // next is more specific
474
- curr = next ;
475
- continue ;
476
- }
477
- if (nextClass .isAssignableFrom (currClass )) { // current more specific
478
- continue ;
479
- }
480
- }
481
- AnnotatedMethod nextM = next .value ;
482
- AnnotatedMethod currM = curr .value ;
483
-
484
- /* 30-May-2014, tatu: Two levels of precedence:
485
- *
486
- * 1. Regular setters ("setX(...)")
487
- * 2. Implicit, possible setters ("x(...)")
488
- */
489
- int priNext = _setterPriority (nextM );
490
- int priCurr = _setterPriority (currM );
491
-
492
- if (priNext != priCurr ) {
493
- if (priNext < priCurr ) {
494
- curr = next ;
495
- }
469
+ AnnotatedMethod selected = _selectSetter (curr .value , next .value );
470
+ if (selected == curr .value ) {
496
471
continue ;
497
472
}
498
- // 11-Dec-2015, tatu: As per [databind#1033] allow pluggable conflict resolution
499
- if (_annotationIntrospector != null ) {
500
- AnnotatedMethod pref = _annotationIntrospector .resolveSetterConflict (_config ,
501
- currM , nextM );
502
-
503
- // note: should be one of nextM/currM; but no need to check
504
- if (pref == currM ) {
505
- continue ;
506
- }
507
- if (pref == nextM ) {
508
- curr = next ;
509
- continue ;
510
- }
473
+ if (selected == next .value ) {
474
+ curr = next ;
475
+ continue ;
511
476
}
512
- throw new IllegalArgumentException (String .format (
513
- "Conflicting setter definitions for property \" %s\" : %s vs %s" ,
514
- getName (), curr .value .getFullName (), next .value .getFullName ()));
477
+ // 10-May-2021, tatu: unbreakable tie, for now; offline handling
478
+ return _selectSetterFromMultiple (curr , next );
515
479
}
480
+
516
481
// One more thing; to avoid having to do it again...
517
482
_setters = curr .withoutNext ();
518
483
return curr .value ;
519
484
}
520
485
486
+ // @since 2.13
487
+ protected AnnotatedMethod _selectSetter (AnnotatedMethod currM , AnnotatedMethod nextM )
488
+ {
489
+ // Allow masking, i.e. do not fail if one is in super-class from the other
490
+ final Class <?> currClass = currM .getDeclaringClass ();
491
+ final Class <?> nextClass = nextM .getDeclaringClass ();
492
+ if (currClass != nextClass ) {
493
+ if (currClass .isAssignableFrom (nextClass )) { // next is more specific
494
+ return nextM ;
495
+ }
496
+ if (nextClass .isAssignableFrom (currClass )) { // current more specific
497
+ return currM ;
498
+ }
499
+ }
500
+
501
+ /* 30-May-2014, tatu: Two levels of precedence:
502
+ *
503
+ * 1. Regular setters ("setX(...)")
504
+ * 2. Implicit, possible setters ("x(...)")
505
+ */
506
+ // 25-Apr-2021, tatu: This is probably wrong, should not rely on
507
+ // hard-coded "set" prefix here.
508
+ int priNext = _setterPriority (nextM );
509
+ int priCurr = _setterPriority (currM );
510
+
511
+ if (priNext != priCurr ) {
512
+ // Smaller value, higher; so, if next has higher precedence:
513
+ if (priNext < priCurr ) {
514
+ return nextM ;
515
+ }
516
+ // otherwise current one has, proceed
517
+ return currM ;
518
+ }
519
+ // 11-Dec-2015, tatu: As per [databind#1033] allow pluggable conflict resolution
520
+ return (_annotationIntrospector == null ) ? null
521
+ : _annotationIntrospector .resolveSetterConflict (_config , currM , nextM );
522
+ }
523
+
524
+ // @since 2.13
525
+ protected AnnotatedMethod _selectSetterFromMultiple (Linked <AnnotatedMethod > curr ,
526
+ Linked <AnnotatedMethod > next )
527
+ {
528
+ throw new IllegalArgumentException (String .format (
529
+ "Conflicting setter definitions for property \" %s\" : %s vs %s" ,
530
+ getName (), curr .value .getFullName (), next .value .getFullName ()));
531
+ }
532
+
521
533
@ Override
522
534
public AnnotatedField getField ()
523
535
{
0 commit comments