15
15
*/
16
16
package org .springframework .data .repository .query ;
17
17
18
- import java .util .ArrayList ;
19
- import java .util .Arrays ;
20
18
import java .util .Iterator ;
21
- import java .util .List ;
22
19
import java .util .Optional ;
23
20
24
21
import org .springframework .data .domain .Pageable ;
36
33
public class ParametersParameterAccessor implements ParameterAccessor {
37
34
38
35
private final Parameters <?, ?> parameters ;
39
- private final List < Object > values ;
36
+ private final Object [] values ;
40
37
41
38
/**
42
39
* Creates a new {@link ParametersParameterAccessor}.
@@ -54,12 +51,13 @@ public ParametersParameterAccessor(Parameters<?, ?> parameters, Object[] values)
54
51
this .parameters = parameters ;
55
52
56
53
if (requiresUnwrapping (values )) {
57
- this .values = new ArrayList <>(values .length );
58
- for (Object value : values ) {
59
- this .values .add (QueryExecutionConverters .unwrap (value ));
54
+ this .values = new Object [values .length ];
55
+
56
+ for (int i = 0 ; i < values .length ; i ++) {
57
+ this .values [i ] = QueryExecutionConverters .unwrap (values [i ]);
60
58
}
61
59
} else {
62
- this .values = Arrays . asList ( values ) ;
60
+ this .values = values ;
63
61
}
64
62
}
65
63
@@ -88,7 +86,7 @@ private static boolean requiresUnwrapping(Object[] values) {
88
86
*
89
87
* @return
90
88
*/
91
- protected List < Object > getValues () {
89
+ protected Object [] getValues () {
92
90
return this .values ;
93
91
}
94
92
@@ -102,7 +100,7 @@ public Pageable getPageable() {
102
100
return Pageable .unpaged ();
103
101
}
104
102
105
- Pageable pageable = (Pageable ) values . get ( parameters .getPageableIndex ()) ;
103
+ Pageable pageable = (Pageable ) values [ parameters .getPageableIndex ()] ;
106
104
107
105
return pageable == null ? Pageable .unpaged () : pageable ;
108
106
}
@@ -115,7 +113,7 @@ public Sort getSort() {
115
113
116
114
if (parameters .hasSortParameter ()) {
117
115
118
- Sort sort = (Sort ) values . get ( parameters .getSortIndex ()) ;
116
+ Sort sort = (Sort ) values [ parameters .getSortIndex ()] ;
119
117
return sort == null ? Sort .unsorted () : sort ;
120
118
}
121
119
@@ -134,7 +132,7 @@ public Sort getSort() {
134
132
public Optional <Class <?>> getDynamicProjection () {
135
133
136
134
return Optional .ofNullable (parameters .hasDynamicProjection () //
137
- ? (Class <?>) values . get ( parameters .getDynamicProjectionIndex ()) //
135
+ ? (Class <?>) values [ parameters .getDynamicProjectionIndex ()] //
138
136
: null );
139
137
}
140
138
@@ -147,7 +145,7 @@ public Optional<Class<?>> getDynamicProjection() {
147
145
public Class <?> findDynamicProjection () {
148
146
149
147
return parameters .hasDynamicProjection () //
150
- ? (Class <?>) values . get ( parameters .getDynamicProjectionIndex ())
148
+ ? (Class <?>) values [ parameters .getDynamicProjectionIndex ()]
151
149
: null ;
152
150
}
153
151
@@ -159,15 +157,15 @@ public Class<?> findDynamicProjection() {
159
157
*/
160
158
@ SuppressWarnings ("unchecked" )
161
159
protected <T > T getValue (int index ) {
162
- return (T ) values . get ( index ) ;
160
+ return (T ) values [ index ] ;
163
161
}
164
162
165
163
/*
166
164
* (non-Javadoc)
167
165
* @see org.springframework.data.repository.query.ParameterAccessor#getBindableValue(int)
168
166
*/
169
167
public Object getBindableValue (int index ) {
170
- return values . get ( parameters .getBindableParameter (index ).getIndex ()) ;
168
+ return values [ parameters .getBindableParameter (index ).getIndex ()] ;
171
169
}
172
170
173
171
/*
@@ -177,7 +175,7 @@ public Object getBindableValue(int index) {
177
175
public boolean hasBindableNullValue () {
178
176
179
177
for (Parameter parameter : parameters .getBindableParameters ()) {
180
- if (values . get ( parameter .getIndex ()) == null ) {
178
+ if (values [ parameter .getIndex ()] == null ) {
181
179
return true ;
182
180
}
183
181
}
0 commit comments