作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
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/
我需要计算像这样存储的 2 个短数据数组的 FFT(重复百万次): 等等。 数组值用黄色和蓝色表示。每个 K 值都有一个大小为 K 的未使用数据空间,我需要跳过。 我对数据进行了重新排序(和 floa
我是一名优秀的程序员,十分优秀!