首页 > 解决方案 > 不兼容的类型 - 无法转换为 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);
  }

标签: java

解决方案


推荐阅读