Class AstActionHandler<C extends AstActionHandler<C,N,A,H>,N,A extends AstAction<N>,H extends AstHandler<N,A>>
- java.lang.Object
-
- com.vladsch.flexmark.util.visitor.AstActionHandler<C,N,A,H>
-
- Type Parameters:
C- subclass of this class to have functions returning this to have the correct typeN- base node type, this class does not care but in specific handlers it should be a common supertype for all nodesA- action type, subclasses ofAstActionandAstHandlerprovide actual functionalityH- handler to invoke the functionality during AST traversal for specific node
- Direct Known Subclasses:
AttributeProviderAdapter,LinkResolverAdapter,NodeVisitor
public abstract class AstActionHandler<C extends AstActionHandler<C,N,A,H>,N,A extends AstAction<N>,H extends AstHandler<N,A>> extends java.lang.ObjectIntended to be completed by subclasses for specific node types and node actions
-
-
Field Summary
Fields Modifier and Type Field Description private @NotNull AstNode<N>astAdapterprivate @NotNull java.util.Map<java.lang.Class<? extends N>,H>customHandlersMap
-
Constructor Summary
Constructors Constructor Description AstActionHandler(@NotNull AstNode<N> astAdapter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CaddActionHandler(H handler)protected CaddActionHandlers(@NotNull H[]... handlers)AgetAction(@NotNull java.lang.Class<?> nodeClass)private AgetAction(H handler)AgetAction(N node)protected HgetHandler(@NotNull java.lang.Class<?> nodeClass)protected HgetHandler(N node)@NotNull java.util.Set<java.lang.Class<? extends N>>getNodeClasses()protected voidprocessChildren(N node, @NotNull java.util.function.BiConsumer<N,A> processor)protected voidprocessNode(N node, boolean withChildren, @NotNull java.util.function.BiConsumer<N,A> processor)Node processing called for every node being processedprotected <R> RprocessNodeOnly(N node, R defaultValue, @NotNull java.util.function.BiFunction<N,A,R> processor)Process the node and return value from the processor
-
-
-
Method Detail
-
addActionHandlers
@SafeVarargs @NotNull protected final C addActionHandlers(@NotNull @NotNull H[]... handlers)
-
getAction
@Nullable public A getAction(@NotNull @NotNull java.lang.Class<?> nodeClass)
-
getHandler
@Nullable protected H getHandler(@NotNull @NotNull java.lang.Class<?> nodeClass)
-
getNodeClasses
@NotNull public @NotNull java.util.Set<java.lang.Class<? extends N>> getNodeClasses()
-
processNode
protected void processNode(@NotNull N node, boolean withChildren, @NotNull @NotNull java.util.function.BiConsumer<N,A> processor)Node processing called for every node being processedOverride this to add customizations to standard processing callback.
- Parameters:
node- node being processedwithChildren- whether to process child nodes if there is no handler for the node typeprocessor- processor to invoke to perform the processing, BiConsumer taking N node, and A action
-
processChildren
protected final void processChildren(@NotNull N node, @NotNull @NotNull java.util.function.BiConsumer<N,A> processor)
-
processNodeOnly
protected final <R> R processNodeOnly(@NotNull N node, R defaultValue, @NotNull @NotNull java.util.function.BiFunction<N,A,R> processor)Process the node and return value from the processor- Type Parameters:
R- type of result returned by processor- Parameters:
node- node to processdefaultValue- default value if no handler is defined for the nodeprocessor- processor to pass the node and handler for processing- Returns:
- result or defaultValue
-
-