Class AbstractNodeItemVisitor<RESULT,​CONTEXT>

  • Type Parameters:
    RESULT - the type of result produced by visitation
    CONTEXT - the type of data to pass to each visited node
    All Implemented Interfaces:
    INodeItemVisitor<RESULT,​CONTEXT>
    Direct Known Subclasses:
    ValidatingNodeItemVisitor

    public abstract class AbstractNodeItemVisitor<RESULT,​CONTEXT>
    extends Object
    implements INodeItemVisitor<RESULT,​CONTEXT>
    Used by implementations of this class to visit a sequence of node items in a directed graph, using depth-first ordering.
    • Method Detail

      • visit

        public final RESULT visit​(@NonNull
                                  INodeItemVisitable item,
                                  CONTEXT context)
        Visit the provided item.
        Parameters:
        item - the item to visit
        context - provides contextual information for use by the visitor
        Returns:
        the result produced by visiting the item
      • visitFlags

        protected RESULT visitFlags​(@NonNull
                                    INodeItem item,
                                    CONTEXT context)
        Visit any child flags associated with the provided item.
        Parameters:
        item - the item to visit
        context - provides contextual information for use by the visitor
        Returns:
        the result produced by visiting the item's flags
      • visitModelChildren

        protected RESULT visitModelChildren​(@NonNull
                                            INodeItem item,
                                            CONTEXT context)
        Visit any child model items associated with the provided item.
        Parameters:
        item - the item to visit
        context - provides contextual information for use by the visitor
        Returns:
        the result produced by visiting the item's child model items
      • shouldVisitNextChild

        protected boolean shouldVisitNextChild​(@NonNull
                                               INodeItem parent,
                                               @NonNull
                                               INodeItem child,
                                               RESULT result,
                                               CONTEXT context)
        Determine if the child should be visited next, or skipped.
        Parameters:
        parent - the parent of the child to visit next
        child - the next child to visit
        result - the current visitation result
        context - provides contextual information for use by the visitor
        Returns:
        true if the child should be visited, or false if the child should be skipped
      • shouldVisitNextChild

        protected boolean shouldVisitNextChild​(@NonNull
                                               INodeItem parent,
                                               @NonNull
                                               IModelNodeItem<?,​?> child,
                                               RESULT result,
                                               CONTEXT context)
        Determine if the child should be visited next, or skipped.
        Parameters:
        parent - the parent of the child to visit next
        child - the next child to visit
        result - the current visitation result
        context - provides contextual information for use by the visitor
        Returns:
        true if the child should be visited, or false if the child should be skipped
      • aggregateResult

        protected RESULT aggregateResult​(RESULT first,
                                         RESULT second,
                                         CONTEXT context)
        Combine two results into a single, aggregate result.
        Parameters:
        first - the original result
        second - the new result to combine with the original result
        context - provides contextual information for use by the visitor
        Returns:
        the combined result