Hi,
I don't understand the question but maybe this will be remotely
useful.
I see the visitor as a "reversed" iteration
usually one does
for(Foo foo: fooCollection){
inspect(foo);
}
notice that you have the control over the iteration i.e. you can stop
at any time and notice the disadvantage, you have to go with the least
common denominator Foo, you could just as well have FooImpl1 and
FooBarImpl in the fooCollection.
If you want to do anything special with FooBarImpl you'd have to do
some sort of instanceof.
but with Visitor you'd do something along the lines of
fooCollection.visit(new Visitor(){
public void visit(Foo foo){ // whatever }
public void visitSpecial(FooBarImpl foo){// called if specific
type}
});
notice you don't really know how the iteration is done and you don't
necessarily have the means to stop it. But notice the advantage of not
needing the instanceof comparisons.
I think this is one of the reasons why there are visitors in SPI so
instanceof is handled nicely.
While on the subject of SPI for fun I wrote some rough scope
validation utility http://pastie.org/385147 (not the best code but it
shows the power of SPI). Basically you can do pretty much anything
you'd like with the SPI. The Dependency and InjectionPoint classes are
very powerful.
Hope this helps in some way. Note you don't necessarily have to use
the visitors. They are very nice but it is possible to go with the
normal for loop style:)
Cheers,
Alen
On Feb 10, 1:28 pm, Anthony MULLER <[email protected]> wrote:
> I saw I could write my own visitor for bindings for instance... But what to
> do with this visitor afterwards?
>
> Cheers,
> Anthony
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---