It's hard to tell because the example isn't realistic, but usually it's better to break the long type into smaller types that are easier to compose and document. Private inner static classes are useful for this.
Sometimes you can run into these issues if you're trying to use Java like it's a true functional language. The type system just isn't strong enough for that, and it's usually more clear to write the code a different way, or use an abstraction like Stream to hide the types.
If you use var to hide the complicated generic type, you've written code that will be difficult to refactor into a function later. The lack of whole program inference makes it less useful (and more dangerous).
1
u/antrn11 Mar 10 '16
Why not? What would be better?