私は、次の工場コンバートFactoryパターン
public class AppleFactory<T extends Fruit>
extends AbstractAppleFactory<Class<T>, TypeOfFruits, Fruits<T>>
{
private static final AppleFactory factroy = new AppleFactory();
private AppleFactory()
{
}
public static Fruits<? extends Fruit> get(Class<? extends Fruit> clazz,
TypeOfFruits typeOfFruits)
{
return (Fruits<? extends Fruit>) factroy.getInstance(clazz, typeOfFruits);
}
@Override
protected Fruits<T> newInstance(Class<T> clazz, TypeOfFruits typeOfFruits)
{
final Fruits<T> fruits;
fruits = new FruitsImpl<T>(clazz, typeOfFruits,"hello");
return fruits;
}
}
を持っていると私はこれを行うことによって、Guiceのモジュールのパタパタに変換しようとしています:
@ImplementedBy(AppleFactoryImpl.class)
public interface AppleFactory<T extends Fruit>
{
Fruits<? extends Fruit> get(Class<? extends Fruit> clazz,
TypeOfFruits typeOfFruits)
}
@Singleton
public class AppleFactoryImpl implements AppleFactory
{
@Override
public Fruits<? extends Fruit> get(Class<? extends Fruit> clazz,
TypeOfFruits typeOfFruits)
{
final Fruits<T> fruits;
fruits = new FruitsImpl<T>(clazz, typeOfFruits,"hello");
return fruits;
}
}
しかし、私はエラーを取得します実装。それはフルーツのためにタイプTを解決できないと言います。
私の最終目標は、すなわち、具体的な実装に
FruitFactory、FruitFactory
を結合し、この工場によって異なる実装を持つことです。これは、プロバイダまたは何か他のものを使用するように変更することができます
、私はアプローチ
に硬すぎないんだけど誰もがこの問題を解決する方法を知っていますか?
最終目標は何ですか? 'FruitFactory' 'FruitFactory 'を具体的な実装にバインドするのですか? –
@DavidRawson、はい、それは最終目標です。私はこの工場の中に果物を入れて初期化することができるのですか? – Schumi
それは素晴らしいです!これを明確にするために質問を編集できますか?それで誰かが答えることができるでしょう –