Top Description Fields Constructors Methods
com.vladsch.flexmark.util.visitor

public abstract Class AstActionHandler<C extends AstActionHandler<C, N, A, H>, N, A extends AstAction<N>, H extends AstHandler<N, A>>

extends Object
Class Inheritance
Type Parameters
<C>
subclass of this class to have functions returning this to have the correct type
<N>
base node type, this class does not care but in specific handlers it should be a common supertype for all nodes
<A>
action type, subclasses of AstAction and AstHandler provide actual functionality
<H>
handler to invoke the functionality during AST traversal for specific node
Imports
org.jetbrains.annotations.NotNull, .Nullable, java.util.HashMap, .Map, .Set, java.util.function.BiConsumer, .BiFunction

Intended to be completed by subclasses for specific node types and node actions

Field Summary

Modifier and TypeField and Description
private final @NotNull AstNode<N>
private final @NotNull Map<Class<? extends N>, H>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected C
addActionHandler(H handler)

protected final C
addActionHandlers(H[]... handlers)

private A
getAction(H handler)

public A
getAction(N node)

public A
getAction(@NotNull Class<?> nodeClass)

protected H
getHandler(N node)

protected H
getHandler(@NotNull Class<?> nodeClass)

public @NotNull Set<Class<? extends N>>
protected final void
processChildren(N node, @NotNull BiConsumer<N, A> processor)

protected void
processNode(N
node being processed
node
,
boolean
whether to process child nodes if there is no handler for the node type
withChildren
,
@NotNull BiConsumer<N, A>
processor to invoke to perform the processing, BiConsumer taking N node, and A action
processor
)

Node processing called for every node being processed

Override this to add customizations to standard processing callback.

protected final <
type of result returned by processor
R
>
R

Returns:

result or defaultValue
processNodeOnly
(N
node to process
node
,
R
default value if no handler is defined for the node
defaultValue
,
@NotNull BiFunction<N, A, R>
processor to pass the node and handler for processing
processor
)

Process the node and return value from the processor

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

astAdapterback to summary
private final @NotNull AstNode<N> astAdapter
Annotations
@NotNull
customHandlersMapback to summary
private final @NotNull Map<Class<? extends N>, H> customHandlersMap
Annotations
@NotNull

Constructor Detail

AstActionHandlerback to summary
public AstActionHandler(@NotNull AstNode<N> astAdapter)

Method Detail

addActionHandlerback to summary
protected C addActionHandler(H handler)
Annotations
@NotNull
addActionHandlersback to summary
protected final C addActionHandlers(H[]... handlers)
Annotations
@SafeVarargs
@NotNull
getActionback to summary
private A getAction(H handler)
Annotations
@Nullable
getActionback to summary
public A getAction(N node)
Annotations
@Nullable
getActionback to summary
public A getAction(@NotNull Class<?> nodeClass)
Annotations
@Nullable
getHandlerback to summary
protected H getHandler(N node)
Annotations
@Nullable
getHandlerback to summary
protected H getHandler(@NotNull Class<?> nodeClass)
Annotations
@Nullable
getNodeClassesback to summary
public @NotNull Set<Class<? extends N>> getNodeClasses()
Annotations
@NotNull
processChildrenback to summary
protected final void processChildren(N node, @NotNull BiConsumer<N, A> processor)
processNodeback to summary
protected void processNode(N node, boolean withChildren, @NotNull BiConsumer<N, A> processor)

Node processing called for every node being processed

Override this to add customizations to standard processing callback.

Parameters
node:N

node being processed

withChildren:boolean

whether to process child nodes if there is no handler for the node type

processor:@NotNull BiConsumer<N, A>

processor to invoke to perform the processing, BiConsumer taking N node, and A action

processNodeOnlyback to summary
protected final <R> R processNodeOnly(N node, R defaultValue, @NotNull BiFunction<N, A, R> processor)

Process the node and return value from the processor

Parameters
<R>
type of result returned by processor
node:N

node to process

defaultValue:R

default value if no handler is defined for the node

processor:@NotNull BiFunction<N, A, R>

processor to pass the node and handler for processing

Returns:R

result or defaultValue