java - 不兼容的类型 - 无法转换为 java.lang.Class
问题描述
这段代码:
@Override
public <T extends Comparable, B extends ComparableBinding> void transactPersistentEntityStore(
String xodusRoot, String dir, boolean isReadOnly,
StoreTransactionalExecutable txn) {
Map<Class<T>, B> propertyTypeMap = new HashMap<Class<T>, B>();
propertyTypeMap.put(EmbeddedArrayIterable.class, EmbeddedEntityBinding.BINDING);
propertyTypeMap.put(EmbeddedEntityIterable.class, EmbeddedEntityBinding.BINDING);
DatabaseManagerImpl.getInstance()
.transactPersistentEntityStore(xodusRoot + dir, isReadOnly, propertyTypeMap, txn);
}
引发编译器错误:
Error:(82,46) java: incompatible types: java.lang.Class<com.backend.model.EmbeddedArrayIterable> cannot be converted to java.lang.Class<T>
即使EmbeddedArrayIterable是
public class EmbeddedArrayIterable implements Serializable, ByteIterable {
}
public interface ByteIterable extends Comparable<ByteIterable> {
}
这里可能缺少什么?
更新:显示transactPersistentEntityStore方法的代码
@Override
public <T extends Comparable, B extends ComparableBinding> void transactPersistentEntityStore(
String dir, boolean isReadOnly, Map<Class<T>, B> customPropertyTypes,
StoreTransactionalExecutable txn) {
final PersistentEntityStore entityStore =
getPersistentEntityStore(dir, isReadOnly, customPropertyTypes);
entityStore.executeInTransaction(txn);
}
解决方案
推荐阅读
- python - 使用 Pyglet 批量绘制 GL_LINE_STRIP
- rust - 锈:Vec
> 进入 Vec - python - PyQtGraph:在没有进程管理器的情况下停止执行
- r - 如何根据行中字段的值添加具有值的列?
- laravel - 我如何解决 laravel Homestead 错误 500
- c# - 如何将某些文件/类/测试移动到新的 Visual Studio 项目中?
- php - PHP 没有看到 REACT 发送的请求
- python - 如何使 python 文件作为单独的进程/线程运行
- xlsx - 我可以使用单元格中的内容来存储提取 xls 公式的选项卡名称吗?
- python - 验证损失有时会飙升