|
22 | 22 | * FIXME: Decide if we're going to go all the way and do validation and error handling |
23 | 23 | * FIXME: We should be using cached MethodHandles for improved performance |
24 | 24 | * |
25 | | - * Lookup order when searching for a readable binding: |
| 25 | + * Lookup order when searching for readable binding for key 'smu': |
26 | 26 | * |
27 | 27 | * 1. Method "getSmu" |
28 | 28 | * 2. Method "smu" |
@@ -116,26 +116,24 @@ public static void takeValueForKey( final Object object, final Object value, fin |
116 | 116 |
|
117 | 117 | /** |
118 | 118 | * @return A KVC binding for the given class and key. |
119 | | - * |
120 | | - * FIXME: KVC in WebObjects follows a slightly different method ordering. Our ordering is different in the way that we try for the exact key name first, for both methods and fields. In other terms, our lookup order is the same. Consider if this is the correct approach // Hugi 2022-10-22 |
121 | 119 | */ |
122 | 120 | private static KVCReadBinding readBindingForKey( final Object object, final String key ) { |
123 | 121 | Objects.requireNonNull( object ); |
124 | 122 | Objects.requireNonNull( key ); |
125 | 123 |
|
126 | 124 | Method method; |
127 | 125 |
|
128 | | - // First we try for just the key |
129 | | - method = readMethod( object, key ); |
| 126 | + final String keyCapitalized = key.substring( 0, 1 ).toUpperCase() + key.substring( 1 ); |
| 127 | + |
| 128 | + // Ugly old bean-style getMethod() |
| 129 | + method = readMethod( object, "get" + keyCapitalized ); |
130 | 130 |
|
131 | 131 | if( method != null ) { |
132 | 132 | return new MethodReadBinding( method ); |
133 | 133 | } |
134 | 134 |
|
135 | | - final String keyCapitalized = key.substring( 0, 1 ).toUpperCase() + key.substring( 1 ); |
136 | | - |
137 | | - // Now we try the old bean-style getMethod() |
138 | | - method = readMethod( object, "get" + keyCapitalized ); |
| 135 | + // A method with the exact key name |
| 136 | + method = readMethod( object, key ); |
139 | 137 |
|
140 | 138 | if( method != null ) { |
141 | 139 | return new MethodReadBinding( method ); |
@@ -478,19 +476,6 @@ public static Object convertValueToFieldType( Object value, Class<?> targetType |
478 | 476 | } |
479 | 477 | } |
480 | 478 |
|
481 | | - // FIXME: Probably not needed? |
482 | | - // public static class NumericMethodReadBinding extends MethodReadBinding { |
483 | | - // |
484 | | - // public NumericMethodReadBinding( Method method ) { |
485 | | - // super( method ); |
486 | | - // } |
487 | | - // |
488 | | - // @Override |
489 | | - // public Object valueInObject( Object object ) { |
490 | | - // return super.valueInObject( object ); |
491 | | - // } |
492 | | - // } |
493 | | - |
494 | 479 | public static class NumericMethodWriteBinding extends MethodWriteBinding { |
495 | 480 |
|
496 | 481 | public NumericMethodWriteBinding( Method method ) { |
|
0 commit comments