Hallo,
ich habe ein Problem mit generics:
wieso ist da der generic type nicht übereinstimmend?
und
Sollte doch von den generic "bounds" übereinstimmen und demnach sollte ein (impliziter) cast funktionieren?
Die konkrete Meldung ist:
Type mismatch: cannot convert from RecordPageContainer<capture#7-of ? extends KeyValuePage<? extends Comparable<? super K>,Record>> to RecordPageContainer<UnorderedKeyValuePage>
und KeyValuePage ist definiert als:
ich habe ein Problem mit generics:
Java:
@SuppressWarnings("unchecked")
final RecordPageContainer<UnorderedKeyValuePage> container = mNodeLog
.isPresent() ? mNodeLog.get().get(key)
: (RecordPageContainer<UnorderedKeyValuePage>) RecordPageContainer.EMPTY_INSTANCE;
if (container.equals(RecordPageContainer.EMPTY_INSTANCE)) {
return getRecordPageContainer(key, PageKind.NODEPAGE);
} else {
return container;
}
wieso ist da der generic type nicht übereinstimmend?
Java:
/**
* Get a the record page container with the full/modified pages from the page
* layer, given the unique page key and the page kind.
*
* @param key
* {@code key} of key/value page to get the record from
* @param pageKind
* kind of page to lookup
* @return {@code the node} or {@code null} if it's not available
* @throws SirixIOException
* if can't read recordPage
* @throws NullPointerException
* if {@code pageKind} is {@code null}
* @throws IllegalArgumentException
* if {@code key} is negative
*/
<K extends Comparable<? super K>, V extends Record, S extends KeyValuePage<K, V>> RecordPageContainer<S> getRecordPageContainer(
@Nonnegative long key, @Nonnull PageKind pageKind)
throws SirixIOException;
und
Java:
public final class UnorderedKeyValuePage implements KeyValuePage<Long, Record>
Sollte doch von den generic "bounds" übereinstimmen und demnach sollte ein (impliziter) cast funktionieren?
Die konkrete Meldung ist:
Type mismatch: cannot convert from RecordPageContainer<capture#7-of ? extends KeyValuePage<? extends Comparable<? super K>,Record>> to RecordPageContainer<UnorderedKeyValuePage>
und KeyValuePage ist definiert als:
Java:
/**
* Key/Value page.
*
* @author Johannes Lichtenberger
*
*/
public interface KeyValuePage<K extends Comparable<? super K>, V extends Record> extends Page
Zuletzt bearbeitet: