Skip to content

Commit

Permalink
Add @nullable to ParametersParameterAccessor.getValue().
Browse files Browse the repository at this point in the history
Add missing Override and Nullable annotations. Update Javadoc to mention correct return value.

Closes #2506
  • Loading branch information
heowc authored and mp911de committed Dec 13, 2021
1 parent ea335f0 commit 8969a55
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@
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
*/
Pageable getPageable();

/**
* 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
*/
Expand Down Expand Up @@ -72,6 +73,7 @@ public interface ParameterAccessor extends Iterable<Object> {
* @param index
* @return
*/
@Nullable
Object getBindableValue(int index);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ protected Object[] getValues() {
* (non-Javadoc)
* @see org.springframework.data.repository.query.ParameterAccessor#getPageable()
*/
@Override
public Pageable getPageable() {

if (!parameters.hasPageableParameter()) {
Expand All @@ -111,6 +112,7 @@ public Pageable getPageable() {
* (non-Javadoc)
* @see org.springframework.data.repository.query.ParameterAccessor#getSort()
*/
@Override
public Sort getSort() {

if (parameters.hasSortParameter()) {
Expand Down Expand Up @@ -158,6 +160,7 @@ public Class<?> findDynamicProjection() {
* @return
*/
@SuppressWarnings("unchecked")
@Nullable
protected <T> T getValue(int index) {
return (T) values[index];
}
Expand All @@ -166,6 +169,7 @@ protected <T> T getValue(int index) {
* (non-Javadoc)
* @see org.springframework.data.repository.query.ParameterAccessor#getBindableValue(int)
*/
@Override
public Object getBindableValue(int index) {
return values[parameters.getBindableParameter(index).getIndex()];
}
Expand All @@ -174,6 +178,7 @@ public Object getBindableValue(int index) {
* (non-Javadoc)
* @see org.springframework.data.repository.query.ParameterAccessor#hasBindableNullValue()
*/
@Override
public boolean hasBindableNullValue() {

for (Parameter parameter : parameters.getBindableParameters()) {
Expand All @@ -189,6 +194,7 @@ public boolean hasBindableNullValue() {
* (non-Javadoc)
* @see org.springframework.data.repository.query.ParameterAccessor#iterator()
*/
@Override
public BindableParameterIterator iterator() {
return new BindableParameterIterator(this);
}
Expand Down Expand Up @@ -223,6 +229,8 @@ public BindableParameterIterator(ParametersParameterAccessor accessor) {
*
* @return
*/
@Nullable
@Override
public Object next() {
return accessor.getBindableValue(currentIndex++);
}
Expand All @@ -231,6 +239,7 @@ public Object next() {
* (non-Javadoc)
* @see java.util.Iterator#hasNext()
*/
@Override
public boolean hasNext() {
return bindableParameterCount > currentIndex;
}
Expand All @@ -239,6 +248,7 @@ public boolean hasNext() {
* (non-Javadoc)
* @see java.util.Iterator#remove()
*/
@Override
public void remove() {
throw new UnsupportedOperationException();
}
Expand Down

0 comments on commit 8969a55

Please sign in to comment.