-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Scenario
For implied names for constructor parameters if we have a variable name that has a suffix that matches the type. In the example below otherPEmailer
has the suffix of the type PEmailer
.
In the case like:
public Foo(PEmailer otherPEmailer) {
...
}
Currently the implied name for this is !otherPEmailer
The expected implied name should be !other
It should be !other
to make the constructor implied name consistent with the implied name that occurs when concrete @Singleton
implement an interface or abstract type and have a similar naming convention.
That is, according to the TCK tests if we have an interface PEmailer
and we have a @Singleton
implementation called OtherPEmailer
that does not have an explicit name it gets an implicit name of other
(due to the type name having a suffix of the interface type.
Test case
@Singleton
public class UseNamedPEmailer {
...
public UseNamedPEmailer(@Named("Other") PEmailer emailer, PEmailer other, PEmailer otherPEmailer) {
...
}
...
The 3 constructor parameters are expected to have qualifier names of:
Other
- because it has this explicitly stated!other
- implied name with no 'type suffix match'!other
- becauseotherPEmailer
has the type suffixPEmailer
The expected generated injection code is:
/**
* Create and register UseNamedPEmailer.
*/
public static void build(Builder builder) {
if (builder.isAddBeanFor(UseNamedPEmailer.class)) {
UseNamedPEmailer bean = new UseNamedPEmailer(builder.get(PEmailer.class,"other"), builder.get(PEmailer.class,"!other"), builder.get(PEmailer.class,"!other"));
builder.register(bean);
}
}