Hi,
does anyone know, why the types don’t match?
Type mismatch. Required: Database<T> Found: Database<JsonResourceManager!>!
In the following function
fun <T, R, W> openDatabase(databaseName: String): Database<T> where T : ResourceManager<R, W>,
R : NodeReadOnlyTrx,
R : NodeCursor,
W : NodeTrx,
W : NodeCursor {
val databaseType = Databases.getDatabaseType(location.resolve(databaseName).toAbsolutePath())
val database: Database<T> =
when (databaseType) {
DatabaseType.JSON -> Databases.openJsonDatabase(location.resolve(databaseName))
DatabaseType.XML -> Databases.openXmlDatabase(location.resolve(databaseName))
}
return database
}
In Java the Database interface is defined as
public interface Database<T extends ResourceManager<? extends NodeReadOnlyTrx, ? extends NodeTrx>>
extends AutoCloseable
public interface JsonResourceManager extends ResourceManager<JsonNodeReadOnlyTrx, JsonNodeTrx>
public final class LocalJsonDatabase extends AbstractLocalDatabase<JsonResourceManager>
public abstract class AbstractLocalDatabase<T extends ResourceManager<? extends NodeReadOnlyTrx, ? extends NodeTrx>>
implements Database<T>
and
Database.openJsonDatabase(Path)
for instance returns Database<JsonResourceManager>
.
In Java this class for instance works:
public final class AllTimeAxis<R extends NodeReadOnlyTrx & NodeCursor, W extends NodeTrx & NodeCursor>
extends AbstractTemporalAxis<R, W>
and a constructor defined as:
/**
* Constructor.
*
* @param resourceManager the resource manager
* @param rtx the read only transactional cursor
*/
public AllTimeAxis(final ResourceManager<R, W> resourceManager, final R rtx) {
works with new AllTimeAxis(jsonResourceManager, rtx)
with a JsonResourceManager
as parameter.
Kind regards
Johannes