私のIDEはNCM_Callableは、このライン上Callable<ReturnInterface<? extends Object>>
に変換することはできません」という不平を言っている私は、オブジェクトの任意の型を含むReturnInterfaceを返す私のECSに呼び出し可能オブジェクトを渡すことができるようにしたいthis.ph.submitCallable(new NCM_Callable(this, new DeviceGroup(this.deviceGroupNames.get(i)), ph)); In the "fetchDevices()" method
Javaのジェネリック引き起こす問題
。
任意の助けをいただければ幸いです。私は<>一般的な定義の私の使い方に問題がある疑いがあるが、私はそれが何であるかを見つけ出すように見えることはできません。@Override
public void fetchDevices() throws Exception {
System.out.println("[NCM_Fetcher]fetchingDevices()");
for (int i = 0; i < this.deviceGroupNames.size(); i++) {
System.out.println("[NCM_Fetcher]fetchingDevices().submitting DeviceGroup Callable " + i+ " of "+this.deviceGroupNames.size());
this.ph.submitCallable(new NCM_Callable(this, new DeviceGroup(this.deviceGroupNames.get(i)), ph));
}
this.ph.execute();//See progressBarhelper below
}
ProgressB
arHelper: "ecs.submit()"に奇妙なエラーがあります。私が読んだことから、ヘルパーメソッドが必要なようですね?どうすれば修正できますか?
public class ProgressBarHelper extends SwingWorker<Void, ReturnInterface> implements ActionListener {
ExecutorService pool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
protected CompletionService<ReturnInterface<?>> ecs;
public final void submitCallable(Callable<? extends ReturnInterface<?>> c) {
//create a map for this future
ecs.submit(c);
this.callables.add(c);//Error here is Callable<CAP#1 cannot be converted to Callable<ReturnInterface<?>>
System.out.println("[ProgressBarHelper]submitted");
}
}
最後に、NCM_CallableクラスはGenericsを使用します。
public class NCM_Callable implements Callable<ReturnInterface<ResultSet>>, ReturnInterface<ResultSet> {
まず[MCVE]作成:
最後に、これはあなたがこの機能を呼び出すことができる方法です。あなたはおそらくプロセスのあなたの問題を解決するでしょう。 – 4castle
[Javaジェネリック、ネストされたワイルドカードのコレクション]の可能な複製(http://stackoverflow.com/questions/6293871/java-generics-nested-collection-of-wildcard) – 4castle
重複していません。 –