DATAKV-197 - Polishing.

Update JavaDoc, fix trailing whitespace and add missing @Nullable annotations to methods potentially returning null values.

Original Pull Request:#28
This commit is contained in:
Christoph Strobl
2017-09-26 13:55:11 +02:00
parent 83057f1288
commit 7a89366075
8 changed files with 18 additions and 10 deletions

View File

@@ -16,6 +16,7 @@
package org.springframework.data.keyvalue.core;
import org.springframework.data.keyvalue.core.query.KeyValueQuery;
import org.springframework.lang.Nullable;
/**
* Resolves the criteria object from given {@link KeyValueQuery}.
@@ -31,9 +32,10 @@ public interface CriteriaAccessor<T> {
* transformation to match the desired type.
*
* @param query must not be {@literal null}.
* @return the criteria extracted from the query.
* @return the criteria extracted from the query. Can be {@literal null}.
* @throws IllegalArgumentException in case the criteria is not valid for usage with specific
* {@link CriteriaAccessor}.
*/
@Nullable
T resolve(KeyValueQuery<?> query);
}

View File

@@ -348,7 +348,7 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
/**
* Execute {@link KeyValueCallback} and require a non-{@literal null} return value.
*
*
* @param action
* @param <T>
* @return

View File

@@ -17,6 +17,7 @@ package org.springframework.data.keyvalue.core;
import org.springframework.data.domain.Sort;
import org.springframework.data.keyvalue.core.query.KeyValueQuery;
import org.springframework.lang.Nullable;
/**
* Resolves the {@link Sort} object from given {@link KeyValueQuery} and potentially converts it into a store specific
@@ -35,5 +36,6 @@ public interface SortAccessor<T> {
* @param query must not be {@literal null}.
* @return {@literal null} in case {@link Sort} has not been defined on {@link KeyValueQuery}.
*/
@Nullable
T resolve(KeyValueQuery<?> query);
}

View File

@@ -52,7 +52,7 @@ class SpelQueryEngine extends QueryEngine<KeyValueAdapter, SpelCriteria, Compara
* @see org.springframework.data.keyvalue.core.QueryEngine#execute(java.lang.Object, java.lang.Object, int, int, java.lang.String)
*/
@Override
public Collection<?> execute(SpelCriteria criteria, Comparator<?> sort, long offset, int rows, String keyspace) {
public Collection<?> execute(@Nullable SpelCriteria criteria, @Nullable Comparator<?> sort, long offset, int rows, String keyspace) {
return sortAndFilterMatchingRange(getRequiredAdapter().getAllOf(keyspace), criteria, sort, offset, rows);
}
@@ -61,13 +61,13 @@ class SpelQueryEngine extends QueryEngine<KeyValueAdapter, SpelCriteria, Compara
* @see org.springframework.data.keyvalue.core.QueryEngine#count(java.lang.Object, java.lang.String)
*/
@Override
public long count(SpelCriteria criteria, String keyspace) {
public long count(@Nullable SpelCriteria criteria, String keyspace) {
return filterMatchingRange(IterableConverter.toList(getRequiredAdapter().getAllOf(keyspace)), criteria, -1, -1)
.size();
}
@SuppressWarnings("unchecked")
private List<?> sortAndFilterMatchingRange(Iterable<?> source, SpelCriteria criteria, @Nullable Comparator sort,
private List<?> sortAndFilterMatchingRange(Iterable<?> source, @Nullable SpelCriteria criteria, @Nullable Comparator sort,
long offset, int rows) {
List<?> tmp = IterableConverter.toList(source);

View File

@@ -20,7 +20,7 @@ import org.springframework.dao.UncategorizedDataAccessException;
/**
* Normal superclass when we can't distinguish anything more specific than "something went wrong with the underlying
* resource".
*
*
* @author Christoph Strobl
* @author Mark Paluch
*/
@@ -30,7 +30,7 @@ public class UncategorizedKeyValueException extends UncategorizedDataAccessExcep
/**
* Creates a new {@link UncategorizedKeyValueException}.
*
*
* @param msg the detail message.
* @param cause the root cause (usually from using a underlying data access API).
*/

View File

@@ -347,8 +347,9 @@ public class KeyValueEvent<T> extends ApplicationEvent {
/**
* Get the current value.
*
* @return
* @return can be {@literal null}.
*/
@Nullable
public T after() {
return getPayload();
}

View File

@@ -33,7 +33,7 @@ public class BasicKeyValuePersistentEntity<T, P extends KeyValuePersistentProper
private static final KeySpaceResolver DEFAULT_FALLBACK_RESOLVER = ClassNameKeySpaceResolver.INSTANCE;
private final String keyspace;
private final @Nullable String keyspace;
/**
* @param information must not be {@literal null}.
@@ -47,6 +47,7 @@ public class BasicKeyValuePersistentEntity<T, P extends KeyValuePersistentProper
this.keyspace = detectKeySpace(information.getType(), fallbackKeySpaceResolver);
}
@Nullable
private static String detectKeySpace(Class<?> type, @Nullable KeySpaceResolver fallback) {
String keySpace = AnnotationBasedKeySpaceResolver.INSTANCE.resolveKeySpace(type);

View File

@@ -16,6 +16,7 @@
package org.springframework.data.keyvalue.core.mapping;
import org.springframework.data.mapping.model.MutablePersistentEntity;
import org.springframework.lang.Nullable;
/**
* @author Christoph Strobl
@@ -27,7 +28,8 @@ public interface KeyValuePersistentEntity<T, P extends KeyValuePersistentPropert
/**
* Get the {@literal keySpace} a given entity assigns to.
*
* @return never {@literal null}.
* @return can be {@literal null}.
*/
@Nullable
String getKeySpace();
}