Now this may sound ridiculous. Why would one want to use e.g. List instead of List<String>? Please let me explain.
I am trying to call the JPA API CriteriaBuilder.greaterThanOrEqualTo, which has the following signature:
<Y extends Comparable<? super Y>> Predicate greaterThanOrEqualTo(Expression<? extends Y> x, Y y);
However, the value of Y is computed dynamically, based on the Class of the target field. Generally, one may use java.util.Date but has to use LocalDate when the JPA field is of type LocalDate, not important. I have a function returning Comparable<*> since there is no other supertype of Date and LocalDate than Comparable.
And here’s the issue: I can’t find a way to cast Comparable<*> to Comparable<Y>. In Java, one can cast to Comparable and suppress the warnings, yet in Kotlin I can’t do that. What should I do? Thanks!