Package magnet

Interface Visitor


  • public interface Visitor
    Implementation of this interface should be used with Scope.accept(Visitor, int) for iterating though instances and subscopes of a scope. Scope visiting begins with iterating through all instances and then through all subscopes.
    • Method Detail

      • onEnterScope

        boolean onEnterScope​(@NotNull
                             @NotNull Visitor.Scope scope,
                             @Nullable
                             @Nullable Visitor.Scope parent)
        Called when new scope is entered.
        Parameters:
        scope - entered scope.
        parent - parent scope of the entered scope.
        Returns:
        true to visit instances of this scope, false to skip instances.
      • onInstance

        boolean onInstance​(@NotNull
                           @NotNull Visitor.Instance instance)
        Called when visiting new instance between onEnterScope(Scope, Scope) and onExitScope(Scope) calls.
        Parameters:
        instance - visited instance.
        Returns:
        true to visit the next instance in the scope or false to skip all other instances in this scope.
      • onExitScope

        void onExitScope​(@NotNull
                         @NotNull Visitor.Scope scope)
        Called when previously entered scope is exited.
        Parameters:
        scope - exited scope.