Class ReflectiveVisitor
- java.lang.Object
-
- org.neo4j.cypherdsl.core.ast.VisitorWithResult
-
- org.neo4j.cypherdsl.core.internal.ReflectiveVisitor
-
- All Implemented Interfaces:
Visitor
@API(status=INTERNAL, since="1.0") public abstract class ReflectiveVisitor extends VisitorWithResultThis is a convenience class implementing aVisitorand it takes care of choosing the right methods to dispatch theVisitor.enter(Visitable)andVisitor.leave(Visitable)calls to.Classes extending this visitor need to provide corresponding
enterandleavemethods taking exactly one argument of the type ofVisitablethey are interested it.The type must be an exact match, this support class doesn't try to find a close match up in the class hierarchy if it doesn't find an exact match.
- Since:
- 1.0
- Author:
- Michael J. Simons, Gerrit Meier
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classReflectiveVisitor.PreEnterResultThis class is an indicator of what should happen after a new visitable has been identified.
-
Field Summary
Fields Modifier and Type Field Description protected Deque<Visitable>currentVisitedElementsKeeps track of the ASTs current level.protected Map<Visitable,Visitor>visitablesAndDelegatesIf theres any special delegate for a dialect or similar for a given visitable, it will be tracked here.
-
Constructor Summary
Constructors Constructor Description ReflectiveVisitor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description EnterResultenterWithResult(Visitable visitable)A method that is used to pass control to some extend from the visitor to theVisitable.protected ReflectiveVisitor.PreEnterResultgetPreEnterResult(Visitable visitable)voidleave(Visitable visitable)Leave aVisitable.protected abstract voidpostLeave(Visitable visitable)This is a hook that is called with the uncasted, raw visitable just after leaving the visitable.protected abstract booleanpreEnter(Visitable visitable)This is a hook that is called with the uncasted, raw visitable just before entering a visitable.-
Methods inherited from class org.neo4j.cypherdsl.core.ast.VisitorWithResult
enter
-
-
-
-
Method Detail
-
preEnter
protected abstract boolean preEnter(Visitable visitable)
This is a hook that is called with the uncasted, raw visitable just before entering a visitable.The hook is called regardless wither a matching
enteris found or not.- Parameters:
visitable- The visitable that is passed on to a matching enter after this call.- Returns:
- true, when visiting of elements should be stopped until this element is left again.
-
getPreEnterResult
protected ReflectiveVisitor.PreEnterResult getPreEnterResult(Visitable visitable)
-
postLeave
protected abstract void postLeave(Visitable visitable)
This is a hook that is called with the uncasted, raw visitable just after leaving the visitable.The hook is called regardless wither a matching
leaveis found or not.- Parameters:
visitable- The visitable that is passed on to a matching leave after this call.
-
enterWithResult
public final EnterResult enterWithResult(Visitable visitable)
Description copied from interface:VisitorA method that is used to pass control to some extend from the visitor to theVisitable. Not all visitables react to this and we don't give any guarantees about which will. This method has been mainly introduced in parallel toVisitor.enter(Visitable)so that existing external implementations ofvisitorswon't break.- Parameters:
visitable- the segment to visit.- Returns:
- A result indicating whether visitation of child elements should continue or not.
-
-