gpt4 book ai didi

android - 当我尝试为接口(interface) Domain Mapper> 提供实现时出错

转载 作者:行者123 更新时间:2023-12-05 00:18:48 26 4
gpt4 key购买 nike

Dagger 2.32
当我尝试为接口(interface) DomainMapper<PlayerDataEntity, List<PlayerModel>> 提供实现时出现以下错误
error: [Dagger/MissingBinding] me.androidbox.data.mappers.DomainMapper<? super me.androidbox.data.entities.PlayerDataEntity,? extends java.util.List<me.androidbox.domain.models.PlayerModel>> cannot be provided without an @Provides-annotated method.
public abstract interface ApplicationComponent {
^
me.androidbox.data.mappers.DomainMapper<? super me.androidbox.data.entities.PlayerDataEntity,? extends java.util.List<me.androidbox.domain.models.PlayerModel>> is injected at
me.androidbox.data.requests.imp.RequestPlayersImp(…, domainMapper)
me.androidbox.data.requests.imp.RequestPlayersImp is requested at
me.androidbox.app.application.ApplicationComponent.requestPlayersImp()

以下类(class):
class RequestPlayersImp @Inject constructor(
private val footballServices: FootballServices,
private val domainMapper: DomainMapper<PlayerDataEntity, List<PlayerModel>>
) : PlayersInteractor {
}

class DomainMapperImp @Inject constructor(): DomainMapper<PlayerDataEntity, List<PlayerModel>> {
}

@Module
interface PlayerModule {

@Binds
fun provideRequestPlayersImp(requestPlayersImp: RequestPlayersImp): PlayersInteractor

@Binds
fun provideFootballServices(mockFootballServices: MockFootballServices): FootballServices

@Binds
fun provideDomainMapper(domainMapperImp: DomainMapperImp): DomainMapper<PlayerDataEntity, List<PlayerModel>>
}
但是,我可以通过创建一个新接口(interface)来解决这个问题:
interface DomainMapperEntityToDomain : DomainMapper<PlayerDataEntity, List<PlayerModel>>
并使用如下。一切编译正常
class RequestPlayersImp @Inject constructor(
private val footballServices: FootballServices,
private val domainMapper: DomainMapperEntityToDomain
) : PlayersInteractor {
}

class DomainMapperImp @Inject constructor(): DomainMapperEntityToDomain {
}

@Binds
fun provideDomainMapper(domainMapperImp: DomainMapperImp): DomainMapperEntityToDomain
我的问题是为什么我不能使用以下界面:
DomainMapper<PlayerDataEntity, List<PlayerModel>>
非常感谢您的任何建议,
数据类以防万一它们很重要
@JsonClass(generateAdapter = true)
class PlayerDataEntity(
val data: List<PlayerEntity>
)

data class PlayerModel(
val playerId: Int,
val firstname: String,
val lastname: String,
val birthday: String,
val age: Int,
val weight: Int,
val height: Int,
)

最佳答案

用这个:

DomainMapper<@JvmSuppressWildcards PlayerDataEntity, @JvmSuppressWildcards List< @JvmSuppressWildcards PlayerModel>>
代替:
DomainMapper<PlayerDataEntity, List<PlayerModel>>
您可以在 this link 中找到有关它的更多详细信息

关于android - 当我尝试为接口(interface) Domain Mapper<PlayerData Entity, List<PlayerModel>> 提供实现时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66229227/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com