java - Provider recursion question -
so, have class bar
should contains factory of bars.
class bar { collection<bar> children; bar(barfactory factory, foo1 foo, foo2 foo2){ } addchild(foo1 foo1){ children.add(factory.create(foo1)); } } class barfactory { bar create(foo1 foo1); }
the problem in describing barfactory. there specific logic dependencies other objects. i've tried use @provides
mechanism, like
@provides barfactory providelogicelementpresenterfactory(dependence d){ final barfactory f = new barfactory(){ @override public bar create(foo1 foo1) { foo2 foo2 = null;//some logic return new bar(/*how pass factory here?*/f, foo1, foo2); } }; return f; }
how describe such recursive structure or there alternative solution issue?
use this
instead of f
in when invoking bar
constructor.
Comments
Post a Comment