How to call Scala curry functions from Java with Generics

A Scala code has a retry mechanism which is based on currying function: object RetryUtil { def retry[T](retry: Int, timeout: FiniteDuration)(exc: => T): T = { // } } I want to call this …

Java generics impossible assignment?

Every time I think I understand generics better (and can answer without compiling), I get to an example where this theory breaks. Here is a very simple example: static void consumer(List<? super …

How to create a generic wrapper for just any method call?

I want to create a helper method that can wrap/convert just any sync method call into an async Mono. The following is close, but shows an error: Required type: Mono Provided: Mono<? …

What is the difference between “ T” and “T” return types in JavaDocs

Still wrapping my head around generics so help would be appreciated.

convert back to class type List from GenericEntity – anonymous class

I am getting class cast exception at line 7 in the code below. I have written line 1-3 to provide data that comes from a rest service call and these line can’t be changed from my side. I must cast the …

incompatible types: int cannot be converted to T

I’m getting this error, here is the necessary code. Assume the methods not here work correctly. Any help would be awesome. (I am coding on a text file in Ubuntu btw) Here is the error message: (after …

Java generics: Map nested json response to Java objects

Scenario: I’m working with an unusual external API in which every attribute is a map with multiple values. In order to convert this response into simple Java objects, I had to do some dirty unboxing. …

Why is this lambda expression cast using an ampersand?

recently I stumbled over the following code in the Java Comparator class: public static <T, U extends Comparable> Comparator comparing( Function<? super …

Static method to count occurrences of a letter in a lower case word using maps

I have to create a class called MakeMap with a single static method called countLetters(). The method should take as a parameter a word formed of lowercase letters and return a map of the counts of …

Wildcard not allowed for Iterable in Java

I have following code setup. But this is not allowed as wildcard is not allowed for Iterable. public interface CustomInterface extends Iterable{….} CustomTypeA extends …