This is an automated email from the ASF dual-hosted git repository.

veithen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ws-axiom.git


The following commit(s) were added to refs/heads/master by this push:
     new be273eba3 Add tips on primitive type injection with @Named to 
migration guide
be273eba3 is described below

commit be273eba31c7320551a2991197aa2be15f14b137
Author: Andreas Veithen-Knowles <[email protected]>
AuthorDate: Fri Mar 20 23:33:31 2026 +0000

    Add tips on primitive type injection with @Named to migration guide
---
 testing/matrix-testsuite/migration.md | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/testing/matrix-testsuite/migration.md 
b/testing/matrix-testsuite/migration.md
index d0b807baa..0585e22c0 100644
--- a/testing/matrix-testsuite/migration.md
+++ b/testing/matrix-testsuite/migration.md
@@ -400,6 +400,39 @@ Note that filtering logic (e.g. skipping values based on a 
condition like
 `ImmutableList` of values passed to the `FanOutNode` (e.g.
 `.stream().filter(...).collect(ImmutableList.toImmutableList())`).
 
+## Tips and lessons learned
+
+### Injecting primitive types
+
+Guice can inject primitive types such as `boolean` directly — there is no need
+to use the boxed wrapper type. On the binding side, use the boxed type
+(`Boolean.class`) since `boolean.class` is not a valid Guice key:
+
+```java
+binder.bind(Boolean.class)
+        .annotatedWith(Names.named("deep"))
+        .toInstance(value);
+```
+
+On the injection side, a primitive field works fine:
+
+```java
+@Inject @Named("deep") private boolean deep;
+```
+
+### Use `@Named` to disambiguate primitive bindings
+
+When a test case (or its fan-out tree) involves more than one dimension of the
+same primitive type, Guice cannot distinguish the bindings by type alone. Use
+`@Named` (from `com.google.inject.name.Named`) on both the `@Inject` field and
+the corresponding `FanOutNode` binding (via `Names.named(...)`) to 
disambiguate.
+This also applies when a single primitive dimension exists — the annotation
+makes the binding self-documenting and avoids conflicts if another dimension of
+the same type is added later.
+
+See the `dom-testsuite` module for an example with two boolean dimensions
+(`"deep"` and `"newChildHasSiblings"`).
+
 ## Checklist
 
 ### Reusable API test suites

Reply via email to