Skip to content

Commit a21d596

Browse files
heowcmp911de
authored andcommitted
Add @nullable to ParametersParameterAccessor.getValue().
Add missing Override and Nullable annotations. Update Javadoc to mention correct return value. Closes #2506
1 parent 8a75200 commit a21d596

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/main/java/org/springframework/data/repository/query/ParameterAccessor.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@
3131
public interface ParameterAccessor extends Iterable<Object> {
3232

3333
/**
34-
* Returns the {@link Pageable} of the parameters, if available. Returns {@code null} otherwise.
34+
* Returns the {@link Pageable} of the parameters, if available. Returns {@link Pageable#unpaged()} otherwise.
3535
*
3636
* @return
3737
*/
3838
Pageable getPageable();
3939

4040
/**
4141
* Returns the sort instance to be used for query creation. Will use a {@link Sort} parameter if available or the
42-
* {@link Sort} contained in a {@link Pageable} if available. Returns {@code null} if no {@link Sort} can be found.
42+
* {@link Sort} contained in a {@link Pageable} if available. Returns {@link Sort#unsorted()} if no {@link Sort} can
43+
* be found.
4344
*
4445
* @return
4546
*/
@@ -72,6 +73,7 @@ public interface ParameterAccessor extends Iterable<Object> {
7273
* @param index
7374
* @return
7475
*/
76+
@Nullable
7577
Object getBindableValue(int index);
7678

7779
/**

src/main/java/org/springframework/data/repository/query/ParametersParameterAccessor.java

+10
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ protected Object[] getValues() {
9696
* (non-Javadoc)
9797
* @see org.springframework.data.repository.query.ParameterAccessor#getPageable()
9898
*/
99+
@Override
99100
public Pageable getPageable() {
100101

101102
if (!parameters.hasPageableParameter()) {
@@ -111,6 +112,7 @@ public Pageable getPageable() {
111112
* (non-Javadoc)
112113
* @see org.springframework.data.repository.query.ParameterAccessor#getSort()
113114
*/
115+
@Override
114116
public Sort getSort() {
115117

116118
if (parameters.hasSortParameter()) {
@@ -158,6 +160,7 @@ public Class<?> findDynamicProjection() {
158160
* @return
159161
*/
160162
@SuppressWarnings("unchecked")
163+
@Nullable
161164
protected <T> T getValue(int index) {
162165
return (T) values[index];
163166
}
@@ -166,6 +169,7 @@ protected <T> T getValue(int index) {
166169
* (non-Javadoc)
167170
* @see org.springframework.data.repository.query.ParameterAccessor#getBindableValue(int)
168171
*/
172+
@Override
169173
public Object getBindableValue(int index) {
170174
return values[parameters.getBindableParameter(index).getIndex()];
171175
}
@@ -174,6 +178,7 @@ public Object getBindableValue(int index) {
174178
* (non-Javadoc)
175179
* @see org.springframework.data.repository.query.ParameterAccessor#hasBindableNullValue()
176180
*/
181+
@Override
177182
public boolean hasBindableNullValue() {
178183

179184
for (Parameter parameter : parameters.getBindableParameters()) {
@@ -189,6 +194,7 @@ public boolean hasBindableNullValue() {
189194
* (non-Javadoc)
190195
* @see org.springframework.data.repository.query.ParameterAccessor#iterator()
191196
*/
197+
@Override
192198
public BindableParameterIterator iterator() {
193199
return new BindableParameterIterator(this);
194200
}
@@ -223,6 +229,8 @@ public BindableParameterIterator(ParametersParameterAccessor accessor) {
223229
*
224230
* @return
225231
*/
232+
@Nullable
233+
@Override
226234
public Object next() {
227235
return accessor.getBindableValue(currentIndex++);
228236
}
@@ -231,6 +239,7 @@ public Object next() {
231239
* (non-Javadoc)
232240
* @see java.util.Iterator#hasNext()
233241
*/
242+
@Override
234243
public boolean hasNext() {
235244
return bindableParameterCount > currentIndex;
236245
}
@@ -239,6 +248,7 @@ public boolean hasNext() {
239248
* (non-Javadoc)
240249
* @see java.util.Iterator#remove()
241250
*/
251+
@Override
242252
public void remove() {
243253
throw new UnsupportedOperationException();
244254
}

0 commit comments

Comments
 (0)