diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/mapping/AggregateReference.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/mapping/AggregateReference.java index a75054588..08ab0b324 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/mapping/AggregateReference.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/mapping/AggregateReference.java @@ -31,14 +31,21 @@ import org.springframework.util.Assert; */ public interface AggregateReference { + /** + * 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 target aggregate type. + * @param target aggregate identifier type. + */ static AggregateReference 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 { public IdOnlyAggregateReference(ID id) { Assert.notNull(id, "Id must not be null"); - this.id = id; } @@ -82,7 +88,6 @@ public interface AggregateReference { @Override public String toString() { - return "IdOnlyAggregateReference{" + "id=" + id + '}'; } }