开发者

trouble in usage of the generic methods

开发者 https://www.devze.com 2023-01-06 04:59 出处:网络
I have a method declared as below <T> T getA开发者_如何学运维dapter(Adaptable adaptable, Class<T> extensionInterface);

I have a method declared as below

<T> T getA开发者_如何学运维dapter(Adaptable adaptable, Class<T> extensionInterface);

and I'm calling it with below argumants

adapterManager.getAdapter(new AWScoreAdapterImpl(null), AWScoreAdapter.class);

Can someone help me understand why the above line is causing the below compile time error

The method getAdapter(Adaptable, Class) in the type AdapterManager is not applicable for the arguments (AWScoreAdapterImpl, Class)


It's nothing to do with generics - your AWScoreAdapterImpl isn't of type Adaptable. Either implement its interface, or extend it if it's a class.

Are you able to post your class definitions here? In particular, Adaptable, AWScoreAdapterImpl and AdapterManager.

0

精彩评论

暂无评论...
验证码 换一张
取 消