In chapter 9 of JPA Pro 2 , there is a code like this:
Is this a Java 8 new feature spEmp.<Integer>get("id) ? I have not yet seen a method call with a generic type in front.
What is that<Integer> mean? Does it mean that get ("id") takes an integer as a parameter?
The weakly typed API, however, cannot return correct generically typed expressions, thereby generating a compiler warning for an unchecked cast. One way to get rid of these pesky warning messages is to use a relatively rare facility of Java generics: parameterized method invocation, as shown in Listing 19's invocation of the get() method to obtain a path expression.
Stephan van Hulst
posted 2 years ago
In the example code they use, it's not necessary because the compiler can infer the generic method type argument from the variable the result is assigned to:
This shows you that this facility is actually even more rare than they say.
If you find that you have to write code that has to pass type arguments explicitly, the API is probably not well-designed.
Amateurs built google. Professionals built the titanic. We can't find the guy that built this tiny ad:
how do I do my own kindle-like thing - without amazon