gnodet-bot commented on code in PR #13471:
URL: https://github.com/apache/maven/pull/13471#discussion_r4261620796
##########
impl/maven-di/src/main/java/org/apache/maven/di/impl/Binding.java:
##########
@@ -92,6 +102,10 @@ public Binding<T> withKey(Key<?> key) {
}
public Binding<T> initializeWith(BindingInitializer<T> bindingInitializer)
{
+ return initializeWith(bindingInitializer, null);
+ }
+
+ Binding<T> initializeWith(BindingInitializer<T> bindingInitializer, Object
registrationIdentity) {
Review Comment:
💡 **Missing contract doc on `registrationIdentity`:** This package-private
overload's second parameter controls two distinct behaviors — what `toString()`
includes and what `getRegistrationIdentity()` returns for deduplication. The
contract is non-obvious: `null` means "generate a unique anonymous identity"
(yields `this` from `getRegistrationIdentity()`, appends initializer info to
`toString()`); non-null means "use this as the stable identity" (enables
equality-based dedup, no `toString()` annotation). A brief Javadoc would save
the next maintainer a trip through the call chain.
##########
impl/maven-di/src/main/java/org/apache/maven/di/impl/Binding.java:
##########
@@ -116,7 +130,13 @@ public Supplier<T> compile(Function<Dependency<?>,
Supplier<?>> compiler) {
@Override
public String toString() {
- return Binding.this.toString();
+ return Binding.this
+ + (registrationIdentity == null ? " initialized by " +
identityString(bindingInitializer) : "");
Review Comment:
💡 **`toString()` asymmetry:** When `registrationIdentity` is `null`, the
output appends `" initialized by <bindingInitializer>"`, giving a useful
diagnostic. When `registrationIdentity` is non-null (i.e. the binding was
registered from a known `Member` source), the appended string is `""` — no
indication the binding is initialized at all. A reader debugging ambiguity
diagnostics would see `BindingToConstructor[..., SomeMethod]` for a plain
constructor binding and `BindingToConstructor[..., SomeMethod]` for an
initialized version of the same binding — indistinguishable.
Consider always appending an initialization marker when
`registrationIdentity != null` and the binding _was_ initialized:
```suggestion
return Binding.this
+ (registrationIdentity == null ? " initialized by "
+ identityString(bindingInitializer) : " (initialized)");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]