How to convert this line from java to kotlin


I’ve got the following code snippet that I need converted to kotlin:

Map<Class<?>, Fetcher> fetchers = Maps.newHashMap();
fetchers.put(, OrgEmployeesFetcher(...))
fetchers.put(, OrgTestersFetcher(...))

where Fetcher is an interface:

public interface Fetcher<I, O> {...}

and OrgEmployeesFetcher, OrgTesttersFetcher are implementations of this interface:

public class OrgEmployeesFetcher implements Fetcher<Object, OrgEmployees>{...}
public class OrgTestersFetcher implements Fetcher<Object, OrgTesters>{...}

I’m having trouble converting the first line: Map<Class<?>, Fetcher> fetchers = Maps.newHashMap();.



val fetchers = mapOf( to OrgEmployeesFetcher(...), 
            to  OrgTestersFetcher(...))

and then use specifiy type explicitly IDE action if you really need type :slight_smile:


Thanks that worked.
BTW, after doing this, intellij showed that the type I should have tried was:

HashMap<Class<out Any>, Fetcher<Any!, out Any!>>

(I used hashMapOf instead of mapOf).