Skip to content

feat(dependency-injection): add toOverriding and asAllInterfaces binding API improvements#31

Merged
deer merged 2 commits intomainfrom
di_api_improvements
Apr 13, 2026
Merged

feat(dependency-injection): add toOverriding and asAllInterfaces binding API improvements#31
deer merged 2 commits intomainfrom
di_api_improvements

Conversation

@deer
Copy link
Copy Markdown
Collaborator

@deer deer commented Apr 13, 2026

toOverriding variantsBindingBuilder gains toOverriding(T value), toOverriding(Class<? extends T>), and toOverriding(Supplier<T>). These replace an existing binding silently rather than throwing BindingAlreadyExistsException, covering the one-off test override use case without needing a full Modules.override() module pair.

asAllInterfacesContext gains a bind(T value) instance overload that returns a BindingBuilder<T> supporting asAllInterfaces() and asAllInterfaces(Predicate<Class<?>>). Calling asAllInterfaces() walks the full interface hierarchy of the bound value's type and registers a binding for each interface, with the default filter excluding java.* interfaces. This eliminates the unchecked-cast loop pattern that currently appears in spawn's AbstractTemplatedLauncher (binding a process instance to each of its interfaces).

SuppressingBindingBuilder in Modules delegates the new toOverriding variants. collectInterfaces uses recursive reflection to gather all interfaces from the full type hierarchy, not just direct ones.

@deer deer merged commit a0fbb03 into main Apr 13, 2026
1 check passed
@deer deer deleted the di_api_improvements branch April 13, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant