Skip to content

Commit 91352c0

Browse files
committed
Remove misleading @Nullable annotation from AggregateReference.getId().
Aggregate references must be valid on their own and a null reference would represent a broken reference as we consider null identifiers as transient. Closes #2104
1 parent fdb0423 commit 91352c0

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/mapping/AggregateReference.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.springframework.data.jdbc.core.mapping;
1717

1818
import java.util.Objects;
19-
import java.util.function.Function;
2019

2120
import org.springframework.lang.Nullable;
2221
import org.springframework.util.Assert;
@@ -35,7 +34,8 @@ public interface AggregateReference<T, ID> {
3534
/**
3635
* Creates an {@link AggregateReference} that refers to the target aggregate root with the given id.
3736
*
38-
* @param id aggregate identifier. Can be a simple value or an composite id (complex object).
37+
* @param id aggregate identifier. Must not be {@literal null}, can be a simple value or a composite id (complex
38+
* object).
3939
* @return
4040
* @param <T> target aggregate type.
4141
* @param <ID> target aggregate identifier type.
@@ -45,9 +45,8 @@ static <T, ID> AggregateReference<T, ID> to(ID id) {
4545
}
4646

4747
/**
48-
* @return the id of the referenced aggregate. May be {@code null}.
48+
* @return the id of the referenced aggregate.
4949
*/
50-
@Nullable
5150
ID getId();
5251

5352
/**
@@ -64,7 +63,6 @@ class IdOnlyAggregateReference<T, ID> implements AggregateReference<T, ID> {
6463
public IdOnlyAggregateReference(ID id) {
6564

6665
Assert.notNull(id, "Id must not be null");
67-
6866
this.id = id;
6967
}
7068

@@ -91,7 +89,6 @@ public int hashCode() {
9189

9290
@Override
9391
public String toString() {
94-
9592
return "IdOnlyAggregateReference{" + "id=" + id + '}';
9693
}
9794
}

0 commit comments

Comments
 (0)