Add ability to suppress warnings on Assisted annotations used in factory interfaces
See original GitHub issueSince the latest version 2.32 something like the following code isn’t possible to use anymore because of the change that the type and identifier combo must be unique:
interface FoobarFactory<T : ViewModel> {
fun create(environmentId: String, wizardId: String, stepId: String): T
}
// there are multiple of such viewmodels that all use those three assisted string parameters,
// which is why FoobarFactory exists.
class FooViewModel @AssistedInject constructor(
@Assisted environmentId: String,
@Assisted wizardId: String,
@Assisted stepId: String
) : ... {
@AssistedFactory
interface Factory : FoobarFactory<FooViewModel>
}
I did try several ways to make this code compatible with 2.32 by e.g. changing @Assisted
in the viewmodel to @Assisted("parametername")
and also adding @Assisted("parametername")
to the ‘template’ interface (FoobarFactory
) but essentially just this worked (in addition to adding the qualifier to the viewmodel argument of course):
class FooViewModel ... {
@AssistedFactory
interface Factory : FoobarFactory<FooViewModel> {
override fun create(
@Assisted("environmentId") environmentId: String,
@Assisted("wizardId") wizardId: String,
@Assisted("stepId") stepId: String
): FooViewModel
}
}
As I have multiple of these FooViewModel factories I’d prefer to not have to duplicate and override the function several times.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:13 (5 by maintainers)
Top Results From Across the Web
The @SuppressWarnings Annotation in Java - GeeksforGeeks
The @SuppressWarnings Annotation in Java ; hiding, It suppresses warnings relative to locals that hide variable ; serial, It makes the compiler ...
Read more >SuppressWarnings - Android Developers
For example, if you annotate a class to suppress one warning and annotate a method to suppress another, both warnings will be suppressed...
Read more >Spring Security without the WebSecurityConfigurerAdapter
Configuring HttpSecurity. In Spring Security 5.4 we introduced the ability to configure HttpSecurity by creating a SecurityFilterChain bean.
Read more >Java @SuppressWarnings annotation examples - CodeJava.net
The @SuppressWarnings annotation type allows Java programmers to disable compilation warnings for a certain part of a program (type, field, ...
Read more >JUnit 5 User Guide
The default orderer will be used for all tests unless the @TestMethodOrder annotation is present on an enclosing test class or test interface....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So this didn’t work:
and then inheriting from that interface like this without declaring the function there
Should be fine. It’s quite a niche use case that I have, so explicitly saying “yes I want to really do this” is probably a nice option.