so my decision - as i cant use template code - is to generally make a tree traversal in a distinct method for each operation.
so instead of
internal override void visitHierarchy(CollectionVisitor visitor)
{
base.visitHierarchy(visitor);
foreach (SomeObject Obj in collection1)
Obj.visitHierarchy(visitor);
foreach (SomeObject Obj in collection2)
Obj.visitHierarchy(visitor);
}
there will be a similar block of code, but implemented for the different operations that need to be executed:
public void visitWithOperation1()
{
super.visitWithOperation1();
foreach (SomeObject Obj in collection1)
Obj.visitWithOperation1();
foreach (SomeObject Obj in collection2)
Obj.visitWithOperation1();
}
and
public void visitWithOperation2()
{
super.visitWithOperation2();
foreach (SomeObject Obj in collection1)
Obj.visitWithOperation2();
foreach (SomeObject Obj in collection2)
Obj.visitWithOperation2();
}
of course there isn't foreach in java... but hope you get the idea....
so this is a little bit tedious approach to rewriting delegates in java, but i hope it works for now
No comments :
Post a Comment