Shawn
04/16/2024, 10:00 PMShawn
04/16/2024, 10:00 PMComponents
here), which also need access to that POJO to perform their own setup.
Components are instantiated by appropriate ComponentSetups
(e.g. FooComponentSetup
sets up a FooComponent
) which are parameterized, and those setups enforce the presence of certain config values in the POJO by requiring that the config conforms to a given type constraint/union using its type parameter—the examples here are ConfigWithFoo
and ConfigWithBar
.
The specifics of how these services are supposed to be bootstrapped isn’t super important, but in the course of using this framework, I’ve run into a weird issue where javac seems to not be able to infer the correct generic type in a particular circumstance, specifically when I try to use a fluent method on a `ComponentSetup`—the method returns itself, and should ostensibly have the exact same generic parameters as the result of the preceding constructor call, but instead, Java infers the generic constraint instead of the concrete class which fulfills that constraint, possibly because it can’t infer a type at allShawn
04/16/2024, 10:01 PMShawn
04/16/2024, 10:02 PMShawn
04/16/2024, 10:03 PMComponentSetup
might not need to be generic, but I haven’t quite sorted out how to keep the type safety without the parameterDrew Hamilton
04/16/2024, 11:13 PMFooComponentSetup
requires T
to extend ServiceConfig & ConfigWithFoo
. Not everything that extends both of these is a MyServiceConfig
. For example, a YourServiceConfig
class could be created that extends both of these but does not extend MyServiceConfig
. So if you type the assignee with MyServiceConfig
, you must also explicitly type the corresponding instantiation with MyServiceConfig
(as you do on lines 66 and 72).Drew Hamilton
04/16/2024, 11:18 PMMyServiceConfig
as the instantiation's type arg the same way it would if you were instantiating a list or whatever. IDK. homer disappear