package router.client.api2;

import java.util.List;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public final class OnChangeCallbackChain
{
  @Nonnull
  private final List<RouteEntry<OnChangeCallbackAsync>> _chain;

  public OnChangeCallbackChain( @Nonnull final List<RouteEntry<OnChangeCallbackAsync>> chain )
  {
    _chain = Objects.requireNonNull( chain );
  }

  public void onChange( @Nullable final String previousLocation,
                        @Nonnull final Runnable abortRoute,
                        @Nonnull final Runnable continueRoute )
  {
    onChange( previousLocation, abortRoute, continueRoute, 0 );
  }

  private void onChange( @Nullable final String previousLocation,
                         @Nonnull final Runnable abortRoute,
                         @Nonnull final Runnable continueRoute,
                         final int index )
  {
    if ( index >= _chain.size() )
    {
      continueRoute.run();
    }
    else
    {
      final RouteEntry<OnChangeCallbackAsync> entry = _chain.get( index );
      entry.getCallback().onChange( previousLocation, entry.getLocation(), new OnChangeControl()
      {
        @Override
        public void abort()
        {
          abortRoute.run();
        }

        @Override
        public void proceed()
        {
          onChange( previousLocation, abortRoute, continueRoute, index + 1 );
        }
      } );
    }
  }
}

@@ -518,37 +518,38 @@
 l Runnable abort
-Route
+Action
 ,%0A              
@@ -582,29 +582,26 @@
 unnable 
-continueRoute
+nextAction
  )%0A  %7B%0A 
@@ -636,36 +636,34 @@
 n, abort
-Route, continueRoute
+Action, nextAction
 , 0 );%0A 
@@ -786,21 +786,22 @@
 le abort
-Route
+Action
 ,%0A      
@@ -843,29 +843,26 @@
 unnable 
-continueRoute
+nextAction
 ,%0A      
@@ -948,29 +948,26 @@
 %7B%0A      
-continueRoute
+nextAction
 .run();%0A
@@ -1238,21 +1238,116 @@
    abort
-Route
+Action.run();%0A        %7D%0A%0A        @Override%0A        public void halt()%0A        %7B%0A          nextAction
 .run();%0A
@@ -1462,28 +1462,26 @@
 bort
-Route, continueRoute
+Action, nextAction
 , in

Implement missing halt callback method and rename actions