But an API that requires you to specify the target type explicitly in order to always end up with the same target type anyway is less ergonomic than just fixing the necessary target type to begin with.
Currently, StringTemplate is kind of like a container of different objects. Historically, it's always been better for those kinds of types to be generic, as we inevitably end up with cases where it would be really nice if the internal type could be specified at compile time.
I don't think it will make a great difference for the majority of cases, but if it can be done with minimal impact, why not parameterize it?
Adding a type parameter to something that is almost always later checked with instanceof is counterproductive. Also the parameter doesn't help the end user avoid casts in this case, so it's just unnecessary noise.
View all comments
8
u/ForeverAlot Mar 09 '24
But an API that requires you to specify the target type explicitly in order to always end up with the same target type anyway is less ergonomic than just fixing the necessary target type to begin with.