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

  • 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
    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.Object
    Intended to be completed by subclasses for specific node types and node actions
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected C addActionHandler​(H handler)  
      protected C addActionHandlers​(H[]... handlers)  
      A getAction​(java.lang.Class<?> nodeClass)  
      A getAction​(N node)  
      protected H getHandler​(java.lang.Class<?> nodeClass)  
      protected H getHandler​(N node)  
      java.util.Set<java.lang.Class<? extends N>> getNodeClasses()  
      protected void processChildren​(N node, java.util.function.BiConsumer<N,​A> processor)  
      protected void processNode​(N node, boolean withChildren, java.util.function.BiConsumer<N,​A> processor)
      Node processing called for every node being processed
      protected <R> R processNodeOnly​(N node, R defaultValue, java.util.function.BiFunction<N,​A,​R> processor)
      Process the node and return value from the processor
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AstActionHandler

        public AstActionHandler​(@NotNull
                                AstNode<N> astAdapter)
    • Method Detail

      • addActionHandlers

        @SafeVarargs
        @NotNull
        protected final C addActionHandlers​(@NotNull
                                            H[]... handlers)
      • addActionHandler

        @NotNull
        protected C addActionHandler​(@NotNull
                                     H handler)
      • getAction

        @Nullable
        public A getAction​(@NotNull
                           N node)
      • getAction

        @Nullable
        public A getAction​(@NotNull
                           java.lang.Class<?> nodeClass)
      • getHandler

        @Nullable
        protected H getHandler​(@NotNull
                               N node)
      • getHandler

        @Nullable
        protected H getHandler​(@NotNull
                               java.lang.Class<?> nodeClass)
      • getNodeClasses

        @NotNull
        public java.util.Set<java.lang.Class<? extends N>> getNodeClasses()
      • processNode

        protected void processNode​(@NotNull
                                   N node,
                                   boolean withChildren,
                                   @NotNull
                                   java.util.function.BiConsumer<N,​A> processor)
        Node processing called for every node being processed

        Override this to add customizations to standard processing callback.

        Parameters:
        node - node being processed
        withChildren - whether to process child nodes if there is no handler for the node type
        processor - processor to invoke to perform the processing, BiConsumer taking N node, and A action
      • processChildren

        protected final void processChildren​(@NotNull
                                             N node,
                                             @NotNull
                                             java.util.function.BiConsumer<N,​A> processor)
      • processNodeOnly

        protected final <R> R processNodeOnly​(@NotNull
                                              N node,
                                              R defaultValue,
                                              @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 process
        defaultValue - default value if no handler is defined for the node
        processor - processor to pass the node and handler for processing
        Returns:
        result or defaultValue