public interface Visitor
WorkflowBean
.
Used with WorkflowBean.accept(Visitor)
- in particular with
WorkflowBundle.accept(Visitor)
to recursively visit every
WorkflowBean of a workflow bundle.
visitEnter(WorkflowBean)
will be called for each
WorkflowBean
which has children, while visit(WorkflowBean)
is called for leaf children.
For instance visiting using Workflow.accept(Visitor)
will call
visitEnter(WorkflowBean)
with the workflow instance, followed by a
visit(WorkflowBean)
on each InputWorkflowPort
and
OutputWorkflowPort
(which are leaf nodes). Further
visitEnter(WorkflowBean)
will be called with a Processor
-
which Processor.accept(Visitor)
will recurse to
InputProcessorPort
etc.
The visitor can avoid visiting a branch of the workflow by returning
false
from visitEnter(WorkflowBean)
, or cancel the
iteration over children by returning false
from
visit(WorkflowBean)
and visitLeave(WorkflowBean)
.
The Visitor.VisitorAdapter
class can be useful for avoiding to implement all
Visitor methods, while Visitor.VisitorWithPath
provides the
VisitorAdapter#getCurrentPath()
.
http://c2.com/cgi/wiki?HierarchicalVisitorPattern
Modifier and Type | Interface and Description |
---|---|
static class |
Visitor.VisitorAdapter |
static class |
Visitor.VisitorWithPath |
Modifier and Type | Method and Description |
---|---|
boolean |
visit(WorkflowBean node)
Called by
WorkflowBean.accept(Visitor) when the visited bean is a
leaf node. |
boolean |
visitEnter(WorkflowBean node)
Called by
WorkflowBean.accept(Visitor) when first visiting a bean
which potentially has children. |
boolean |
visitLeave(WorkflowBean node)
Called by
WorkflowBean.accept(Visitor) before leaving a bean
previously visited with visitEnter(WorkflowBean) . |
boolean visit(WorkflowBean node)
WorkflowBean.accept(Visitor)
when the visited bean is a
leaf node.
A leaf node is a bean that can't have children, like
InputWorkflowPort
, PortNode
or PropertyLiteral
.
node
- the currently visited WorkflowBean
true
if the visits over the current beans' siblings
should continue, false
to immediately leave the
parent.visitEnter(WorkflowBean)
boolean visitEnter(WorkflowBean node)
WorkflowBean.accept(Visitor)
when first visiting a bean
which potentially has children.
After visiting the children (which could be none),
WorkflowBean.accept(Visitor)
on the current bean will call
visitLeave(WorkflowBean)
.
Note that a bean can have some children which are visited with
visit(WorkflowBean)
and others which are visited with
visitEnter(WorkflowBean)
(depending on if they themselves can
have children).
node
- the currently visited WorkflowBean
true
if the children of this bean should be visited.visit(WorkflowBean)
,
visitLeave(WorkflowBean)
boolean visitLeave(WorkflowBean node)
WorkflowBean.accept(Visitor)
before leaving a bean
previously visited with visitEnter(WorkflowBean)
. This is called
after all of the bean's children have been recursively visited, even if
any of those aborted the visit by returning false
.node
- the currently visited WorkflowBean
false
if the visits over the current beans' siblings
should continue, false
to immediately leave the
parent.Copyright © 2014 myGrid. All rights reserved.