Skip to content

Commit 6ae2380

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 7ad8b31 commit 6ae2380

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,21 @@
3131
*/
3232
public interface AggregateReference<T, ID> {
3333

34+
/**
35+
* Creates an {@link AggregateReference} that refers to the target aggregate root with the given id.
36+
*
37+
* @param id aggregate identifier. Must not be {@literal null}, can be a simple value.
38+
* @return
39+
* @param <T> target aggregate type.
40+
* @param <ID> target aggregate identifier type.
41+
*/
3442
static <T, ID> AggregateReference<T, ID> to(ID id) {
3543
return new IdOnlyAggregateReference<>(id);
3644
}
3745

3846
/**
39-
* @return the id of the referenced aggregate. May be {@code null}.
47+
* @return the id of the referenced aggregate.
4048
*/
41-
@Nullable
4249
ID getId();
4350

4451
/**
@@ -55,7 +62,6 @@ class IdOnlyAggregateReference<T, ID> implements AggregateReference<T, ID> {
5562
public IdOnlyAggregateReference(ID id) {
5663

5764
Assert.notNull(id, "Id must not be null");
58-
5965
this.id = id;
6066
}
6167

@@ -82,7 +88,6 @@ public int hashCode() {
8288

8389
@Override
8490
public String toString() {
85-
8691
return "IdOnlyAggregateReference{" + "id=" + id + '}';
8792
}
8893
}

0 commit comments

Comments
 (0)