Class RouteList

All Implemented Interfaces:
Iterable<Route>, Collection<Route>, List<Route>

public final class RouteList extends WrapperList<Route>
Modifiable list of routes with some helper methods. Note that this class implements the List interface using the Route class as the generic type. This allows you to use an instance of this class as any other List, in particular all the helper methods in Collections.

Note that structural changes to this list are thread-safe, using an underlying CopyOnWriteArrayList.
Author:
Jerome Louvel
See Also:
  • Constructor Details

    • RouteList

      public RouteList()
      Constructor.
    • RouteList

      public RouteList(List<Route> delegate)
      Constructor.
      Parameters:
      delegate - The delegate list.
  • Method Details

    • getBest

      public Route getBest(Request request, Response response, float requiredScore)
      Returns the best route match for a given call.
      Parameters:
      request - The request to score.
      response - The response to score.
      requiredScore - The minimum score required to have a match.
      Returns:
      The best route match or null.
    • getFirst

      public Route getFirst(Request request, Response response, float requiredScore)
      Returns the first route match for a given call.
      Parameters:
      request - The request to score.
      response - The response to score.
      requiredScore - The minimum score required to have a match.
      Returns:
      The first route match or null.
    • getLast

      public Route getLast(Request request, Response response, float requiredScore)
      Returns the last route match for a given call.
      Parameters:
      request - The request to score.
      response - The response to score.
      requiredScore - The minimum score required to have a match.
      Returns:
      The last route match or null.
    • getNext

      public Route getNext(Request request, Response response, float requiredScore)
      Returns a next route match in a round robin mode for a given call.
      Parameters:
      request - The request to score.
      response - The response to score.
      requiredScore - The minimum score required to have a match.
      Returns:
      A next route or null.
    • getRandom

      public Route getRandom(Request request, Response response, float requiredScore)
      Returns a random route match for a given call. Note that the current implementation doesn't uniformly return routes unless they all score above the required score.
      Parameters:
      request - The request to score.
      response - The response to score.
      requiredScore - The minimum score required to have a match.
      Returns:
      A random route or null.
    • removeAll

      public void removeAll(Restlet target)
      Removes all routes routing to a given target.
      Parameters:
      target - The target Restlet to detach.
    • subList

      public RouteList subList(int fromIndex, int toIndex)
      Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
      Specified by:
      subList in interface List<Route>
      Overrides:
      subList in class WrapperList<Route>
      Parameters:
      fromIndex - The start position.
      toIndex - The end position (exclusive).
      Returns:
      The sub-list.