Incompatible types: Required: T Found: Object - IntelliJ

The project I'm working on has this method (in abbreviated form):

   public <T> T query(
        final Extractor<T> extractor, final List result) {
                //...
               return extractor.extract(result) 
                //...
    }

using an Extractor defined as:

public interface Extractor<T> {
    T extract(List<Map<String, Object>> result);
}

There is no error in Eclipse, but IntelliJ refuses to compile the class with Incompatible types: Required: T Found: Object, the only way is if I return the return value of T or return Object, and I cannot understand why this is otherwise.

+4
source share
2 answers

You need to add a type argument to the parameter:

query(final Extractor<T> extractor, final List<Map<String, Object>> result){

Error message due to type mismatch ( Raw Type ). Here's what the raw type says:

, API (, ) JDK 5.0. , , , - ( ) .

+1

Eclipse.

, raw List.

query :

public <T> T query(final Extractor<T> extractor, final List<Map<String, Object>> result)

.

+3

Source: https://habr.com/ru/post/1684221/


All Articles