Browse Source

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
pull/2110/head
Mark Paluch 4 months ago
parent
commit
6ae2380e88
No known key found for this signature in database
GPG Key ID: 55BC6374BAA9D973
  1. 13
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/mapping/AggregateReference.java

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

@ -31,14 +31,21 @@ import org.springframework.util.Assert; @@ -31,14 +31,21 @@ import org.springframework.util.Assert;
*/
public interface AggregateReference<T, ID> {
/**
* Creates an {@link AggregateReference} that refers to the target aggregate root with the given id.
*
* @param id aggregate identifier. Must not be {@literal null}, can be a simple value.
* @return
* @param <T> target aggregate type.
* @param <ID> target aggregate identifier type.
*/
static <T, ID> AggregateReference<T, ID> to(ID id) {
return new IdOnlyAggregateReference<>(id);
}
/**
* @return the id of the referenced aggregate. May be {@code null}.
* @return the id of the referenced aggregate.
*/
@Nullable
ID getId();
/**
@ -55,7 +62,6 @@ public interface AggregateReference<T, ID> { @@ -55,7 +62,6 @@ public interface AggregateReference<T, ID> {
public IdOnlyAggregateReference(ID id) {
Assert.notNull(id, "Id must not be null");
this.id = id;
}
@ -82,7 +88,6 @@ public interface AggregateReference<T, ID> { @@ -82,7 +88,6 @@ public interface AggregateReference<T, ID> {
@Override
public String toString() {
return "IdOnlyAggregateReference{" + "id=" + id + '}';
}
}

Loading…
Cancel
Save