Add @Nullable to ParametersParameterAccessor.getValue().
Add missing Override and Nullable annotations. Update Javadoc to mention correct return value. Closes #2506
This commit is contained in:
@@ -31,7 +31,7 @@ import org.springframework.lang.Nullable;
|
||||
public interface ParameterAccessor extends Iterable<Object> {
|
||||
|
||||
/**
|
||||
* Returns the {@link Pageable} of the parameters, if available. Returns {@code null} otherwise.
|
||||
* Returns the {@link Pageable} of the parameters, if available. Returns {@link Pageable#unpaged()} otherwise.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -39,7 +39,8 @@ public interface ParameterAccessor extends Iterable<Object> {
|
||||
|
||||
/**
|
||||
* Returns the sort instance to be used for query creation. Will use a {@link Sort} parameter if available or the
|
||||
* {@link Sort} contained in a {@link Pageable} if available. Returns {@code null} if no {@link Sort} can be found.
|
||||
* {@link Sort} contained in a {@link Pageable} if available. Returns {@link Sort#unsorted()} if no {@link Sort} can
|
||||
* be found.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -72,6 +73,7 @@ public interface ParameterAccessor extends Iterable<Object> {
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
Object getBindableValue(int index);
|
||||
|
||||
/**
|
||||
|
||||
@@ -96,6 +96,7 @@ public class ParametersParameterAccessor implements ParameterAccessor {
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.query.ParameterAccessor#getPageable()
|
||||
*/
|
||||
@Override
|
||||
public Pageable getPageable() {
|
||||
|
||||
if (!parameters.hasPageableParameter()) {
|
||||
@@ -111,6 +112,7 @@ public class ParametersParameterAccessor implements ParameterAccessor {
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.query.ParameterAccessor#getSort()
|
||||
*/
|
||||
@Override
|
||||
public Sort getSort() {
|
||||
|
||||
if (parameters.hasSortParameter()) {
|
||||
@@ -158,6 +160,7 @@ public class ParametersParameterAccessor implements ParameterAccessor {
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
protected <T> T getValue(int index) {
|
||||
return (T) values[index];
|
||||
}
|
||||
@@ -166,6 +169,7 @@ public class ParametersParameterAccessor implements ParameterAccessor {
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.query.ParameterAccessor#getBindableValue(int)
|
||||
*/
|
||||
@Override
|
||||
public Object getBindableValue(int index) {
|
||||
return values[parameters.getBindableParameter(index).getIndex()];
|
||||
}
|
||||
@@ -174,6 +178,7 @@ public class ParametersParameterAccessor implements ParameterAccessor {
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.query.ParameterAccessor#hasBindableNullValue()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasBindableNullValue() {
|
||||
|
||||
for (Parameter parameter : parameters.getBindableParameters()) {
|
||||
@@ -189,6 +194,7 @@ public class ParametersParameterAccessor implements ParameterAccessor {
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.query.ParameterAccessor#iterator()
|
||||
*/
|
||||
@Override
|
||||
public BindableParameterIterator iterator() {
|
||||
return new BindableParameterIterator(this);
|
||||
}
|
||||
@@ -223,6 +229,8 @@ public class ParametersParameterAccessor implements ParameterAccessor {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public Object next() {
|
||||
return accessor.getBindableValue(currentIndex++);
|
||||
}
|
||||
@@ -231,6 +239,7 @@ public class ParametersParameterAccessor implements ParameterAccessor {
|
||||
* (non-Javadoc)
|
||||
* @see java.util.Iterator#hasNext()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return bindableParameterCount > currentIndex;
|
||||
}
|
||||
@@ -239,6 +248,7 @@ public class ParametersParameterAccessor implements ParameterAccessor {
|
||||
* (non-Javadoc)
|
||||
* @see java.util.Iterator#remove()
|
||||
*/
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user