@@ -43,13 +43,15 @@ public abstract class AbstractNamedValueArgumentResolver implements HttpServiceA
43
43
44
44
protected final Log logger = LogFactory .getLog (getClass ());
45
45
46
+
47
+ @ Nullable
46
48
private final ConversionService conversionService ;
47
49
48
50
private final Map <MethodParameter , NamedValueInfo > namedValueInfoCache = new ConcurrentHashMap <>(256 );
49
51
50
52
51
53
/**
52
- * Create an instance .
54
+ * Constructor for a resolver to a String value .
53
55
* @param conversionService the {@link ConversionService} to use to format
54
56
* Object to String values
55
57
*/
@@ -58,12 +60,11 @@ protected AbstractNamedValueArgumentResolver(ConversionService conversionService
58
60
this .conversionService = conversionService ;
59
61
}
60
62
61
-
62
63
/**
63
- * Return the configured {@link ConversionService} .
64
+ * Constructor for a resolver to an Object value, without conversion .
64
65
*/
65
- public ConversionService getConversionService () {
66
- return this .conversionService ;
66
+ protected AbstractNamedValueArgumentResolver () {
67
+ this .conversionService = null ;
67
68
}
68
69
69
70
@@ -166,8 +167,8 @@ private void addSingleValue(
166
167
value = defaultValue ;
167
168
}
168
169
169
- if (!(value instanceof String )) {
170
- value = getConversionService () .convert (value , String .class );
170
+ if (this . conversionService != null && !(value instanceof String )) {
171
+ value = this . conversionService .convert (value , String .class );
171
172
}
172
173
173
174
if (value == null ) {
@@ -179,17 +180,19 @@ private void addSingleValue(
179
180
logger .trace ("Resolved " + valueLabel + " value '" + name + ":" + value + "'" );
180
181
}
181
182
182
- addRequestValue (name , ( String ) value , requestValues );
183
+ addRequestValue (name , value , requestValues );
183
184
}
184
185
185
186
/**
186
187
* Add the given, single request value. This may be called multiples times
187
188
* if the request value is multivalued.
189
+ * <p>If the resolver was created with a {@link ConversionService}, the value
190
+ * will have been converted to a String and may be cast down.
188
191
* @param name the request value name
189
192
* @param value the value
190
193
* @param requestValues builder to add the request value to
191
194
*/
192
- protected abstract void addRequestValue (String name , String value , HttpRequestValues .Builder requestValues );
195
+ protected abstract void addRequestValue (String name , Object value , HttpRequestValues .Builder requestValues );
193
196
194
197
195
198
/**
0 commit comments