15
15
*/
16
16
package org .springframework .data .mongodb .repository .query ;
17
17
18
- import lombok .Data ;
19
- import lombok .RequiredArgsConstructor ;
18
+ import lombok .Value ;
20
19
21
20
import java .util .ArrayList ;
22
21
import java .util .LinkedHashMap ;
@@ -144,19 +143,24 @@ private void postProcessQuotedBinding(StringBuffer buffer, String valueForBindin
144
143
while (quotationMark != '\'' && quotationMark != '"' ) {
145
144
146
145
quotationMarkIndex --;
146
+
147
147
if (quotationMarkIndex < 0 ) {
148
148
throw new IllegalArgumentException ("Could not find opening quotes for quoted parameter" );
149
149
}
150
+
150
151
quotationMark = buffer .charAt (quotationMarkIndex );
151
152
}
152
153
153
154
if (valueForBinding .startsWith ("{" )) { // remove quotation char before the complex object string
155
+
154
156
buffer .deleteCharAt (quotationMarkIndex );
157
+
155
158
} else {
156
159
157
160
if (quotationMark == '\'' ) {
158
161
buffer .replace (quotationMarkIndex , quotationMarkIndex + 1 , "\" " );
159
162
}
163
+
160
164
buffer .append ("\" " );
161
165
}
162
166
}
@@ -220,7 +224,9 @@ private Object evaluateExpression(String expressionString, MongoParameters param
220
224
private Pattern createReplacementPattern (List <ParameterBinding > bindings ) {
221
225
222
226
StringBuilder regex = new StringBuilder ();
227
+
223
228
for (ParameterBinding binding : bindings ) {
229
+
224
230
regex .append ("|" );
225
231
regex .append (Pattern .quote (binding .getParameter ()));
226
232
regex .append ("['\" ]?" ); // potential quotation char (as in { foo : '?0' }).
@@ -238,10 +244,9 @@ private Pattern createReplacementPattern(List<ParameterBinding> bindings) {
238
244
*/
239
245
private Placeholder extractPlaceholder (String groupName ) {
240
246
241
- if (!groupName .endsWith ("'" ) && !groupName .endsWith ("\" " )) {
242
- return new Placeholder (groupName , false );
243
- }
244
- return new Placeholder (groupName .substring (0 , groupName .length () - 1 ), true );
247
+ return !groupName .endsWith ("'" ) && !groupName .endsWith ("\" " ) ? //
248
+ Placeholder .of (groupName , false ) : //
249
+ Placeholder .of (groupName .substring (0 , groupName .length () - 1 ), true );
245
250
}
246
251
247
252
/**
@@ -311,9 +316,11 @@ public MongoParameters getParameters() {
311
316
private static Map <Placeholder , ParameterBinding > mapBindings (List <ParameterBinding > bindings ) {
312
317
313
318
Map <Placeholder , ParameterBinding > map = new LinkedHashMap <Placeholder , ParameterBinding >(bindings .size (), 1 );
319
+
314
320
for (ParameterBinding binding : bindings ) {
315
- map .put (new Placeholder (binding .getParameter (), binding .isQuoted ()), binding );
321
+ map .put (Placeholder . of (binding .getParameter (), binding .isQuoted ()), binding );
316
322
}
323
+
317
324
return map ;
318
325
}
319
326
}
@@ -324,8 +331,7 @@ private static Map<Placeholder, ParameterBinding> mapBindings(List<ParameterBind
324
331
* @author Mark Paluch
325
332
* @since 1.9
326
333
*/
327
- @ Data
328
- @ RequiredArgsConstructor
334
+ @ Value (staticConstructor = "of" )
329
335
static class Placeholder {
330
336
331
337
private final String parameter ;
0 commit comments