Skip to content

Commit cf6e82d

Browse files
christophstroblmp911de
authored andcommitted
Migrate to JSpecify annotations for nullability constraints.
Closes #618 Original pull request: #625
1 parent 958c00e commit cf6e82d

File tree

53 files changed

+142
-153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+142
-153
lines changed

pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
<version>${querydsl}</version>
4646
<optional>true</optional>
4747
</dependency>
48-
4948
</dependencies>
5049

5150
<build>
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* Key-Value annotations for declarative keyspace configuration.
33
*/
4-
@org.springframework.lang.NonNullApi
5-
@org.springframework.lang.NonNullFields
4+
@org.jspecify.annotations.NullMarked
65
package org.springframework.data.keyvalue.annotation;

src/main/java/org/springframework/data/keyvalue/aot/KeyValueRuntimeHints.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
import java.util.Arrays;
1919
import java.util.List;
2020

21+
import org.jspecify.annotations.Nullable;
2122
import org.springframework.aot.hint.ExecutableMode;
2223
import org.springframework.aot.hint.MemberCategory;
2324
import org.springframework.aot.hint.RuntimeHints;
2425
import org.springframework.aot.hint.RuntimeHintsRegistrar;
2526
import org.springframework.aot.hint.TypeReference;
2627
import org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery;
27-
import org.springframework.lang.Nullable;
2828

2929
/**
3030
* {@link RuntimeHintsRegistrar} for KeyValue.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* Support classes for key-value ahead of time computation
3+
*/
4+
@org.jspecify.annotations.NullMarked
5+
package org.springframework.data.keyvalue.aot;

src/main/java/org/springframework/data/keyvalue/core/AbstractKeyValueAdapter.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
import java.util.Collection;
1919
import java.util.Comparator;
2020

21+
import org.jspecify.annotations.Nullable;
2122
import org.springframework.data.keyvalue.core.query.KeyValueQuery;
22-
import org.springframework.lang.Nullable;
2323

2424
/**
2525
* Base implementation of {@link KeyValueAdapter} holds {@link QueryEngine} to delegate {@literal find} and
@@ -69,15 +69,13 @@ protected AbstractKeyValueAdapter(@Nullable QueryEngine<? extends KeyValueAdapte
6969
return engine;
7070
}
7171

72-
@Nullable
7372
@Override
74-
public <T> T get(Object id, String keyspace, Class<T> type) {
73+
public <T> @Nullable T get(Object id, String keyspace, Class<T> type) {
7574
return type.cast(get(id, keyspace));
7675
}
7776

78-
@Nullable
7977
@Override
80-
public <T> T delete(Object id, String keyspace, Class<T> type) {
78+
public <T> @Nullable T delete(Object id, String keyspace, Class<T> type) {
8179
return type.cast(delete(id, keyspace));
8280
}
8381

src/main/java/org/springframework/data/keyvalue/core/CriteriaAccessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616
package org.springframework.data.keyvalue.core;
1717

18+
import org.jspecify.annotations.Nullable;
1819
import org.springframework.data.keyvalue.core.query.KeyValueQuery;
19-
import org.springframework.lang.Nullable;
2020

2121
/**
2222
* Resolves the criteria object from given {@link KeyValueQuery}.

src/main/java/org/springframework/data/keyvalue/core/ForwardingCloseableIterator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
import java.util.Iterator;
1919

20+
import org.jspecify.annotations.Nullable;
2021
import org.springframework.data.util.CloseableIterator;
21-
import org.springframework.lang.Nullable;
2222
import org.springframework.util.Assert;
2323

2424
/**

src/main/java/org/springframework/data/keyvalue/core/GeneratingIdAccessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.springframework.data.keyvalue.core;
1717

18+
import org.jspecify.annotations.Nullable;
1819
import org.springframework.data.mapping.IdentifierAccessor;
1920
import org.springframework.data.mapping.PersistentProperty;
2021
import org.springframework.data.mapping.PersistentPropertyAccessor;
@@ -55,7 +56,7 @@ class GeneratingIdAccessor implements IdentifierAccessor {
5556
}
5657

5758
@Override
58-
public Object getIdentifier() {
59+
public @Nullable Object getIdentifier() {
5960
return accessor.getProperty(identifierProperty);
6061
}
6162

src/main/java/org/springframework/data/keyvalue/core/KeyValueAdapter.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
import java.util.Collection;
1919
import java.util.Map;
2020

21+
import org.jspecify.annotations.Nullable;
2122
import org.springframework.beans.factory.DisposableBean;
2223
import org.springframework.data.keyvalue.core.query.KeyValueQuery;
2324
import org.springframework.data.util.CloseableIterator;
24-
import org.springframework.lang.Nullable;
2525

2626
/**
2727
* {@link KeyValueAdapter} unifies access and shields the underlying key/value specific implementation.
@@ -39,7 +39,7 @@ public interface KeyValueAdapter extends DisposableBean {
3939
* @param keyspace must not be {@literal null}.
4040
* @return the item previously associated with the id.
4141
*/
42-
Object put(Object id, Object item, String keyspace);
42+
@Nullable Object put(Object id, Object item, String keyspace);
4343

4444
/**
4545
* Check if a object with given id exists in keyspace.
@@ -69,8 +69,7 @@ public interface KeyValueAdapter extends DisposableBean {
6969
* @return {@literal null} in case no matching item exists.
7070
* @since 1.1
7171
*/
72-
@Nullable
73-
<T> T get(Object id, String keyspace, Class<T> type);
72+
<T> @Nullable T get(Object id, String keyspace, Class<T> type);
7473

7574
/**
7675
* Delete and return the object with given type and id.
@@ -91,16 +90,15 @@ public interface KeyValueAdapter extends DisposableBean {
9190
* @return {@literal null} if object could not be found
9291
* @since 1.1
9392
*/
94-
@Nullable
95-
<T> T delete(Object id, String keyspace, Class<T> type);
93+
<T> @Nullable T delete(Object id, String keyspace, Class<T> type);
9694

9795
/**
9896
* Get all elements for given keyspace.
9997
*
10098
* @param keyspace must not be {@literal null}.
10199
* @return empty {@link Collection} if nothing found.
102100
*/
103-
Iterable<?> getAllOf(String keyspace);
101+
Iterable<Object> getAllOf(String keyspace);
104102

105103
/**
106104
* Get all elements for given keyspace.
@@ -132,7 +130,7 @@ default <T> Iterable<T> getAllOf(String keyspace, Class<T> type) {
132130
* @since 2.5
133131
*/
134132
@SuppressWarnings("unchecked")
135-
default <T> CloseableIterator<Map.Entry<Object, T>> entries(String keyspace, Class<T> type) {
133+
default <T> CloseableIterator<Map.Entry<Object,T>> entries(String keyspace, Class<T> type) {
136134
return (CloseableIterator) entries(keyspace);
137135
}
138136

src/main/java/org/springframework/data/keyvalue/core/KeyValueCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.springframework.data.keyvalue.core;
1717

18-
import org.springframework.lang.Nullable;
18+
import org.jspecify.annotations.Nullable;
1919

2020
/**
2121
* Generic callback interface for code that operates on a {@link KeyValueAdapter}. This is particularly useful for

0 commit comments

Comments
 (0)