Class Route

java.lang.Object
com.yahoo.messagebus.routing.Route

public class Route extends Object

A route is a list of hops that are resolved from first to last as a routable moves from source to destination. A route may be changed at any time be either application logic or an invoked RoutingPolicy, so no guarantees on actual path can be given without the full knowledge of all that logic.

To construct a route you may either use the factory method parse(String) to produce a route instance from a string representation, or you may build one programatically through the hop accessors.

Author:
bratseth, Simon Thoresen Hult
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an empty route that contains no hops.
    Route(Route route)
    The copy constructor ignores integrity, it simply duplicates the list of hops in the other route.
    Route(List<Hop> hops)
    Constructs a route based on a list of hops.
  • Method Summary

    Modifier and Type
    Method
    Description
    addHop(Hop hop)
    Adds a hop to the list of hops that make up this route.
    Clears the list of hops that make up this route.
    boolean
     
    getHop(int i)
    Returns the hop at the given index.
    int
    Returns the number of hops that make up this route.
    int
     
    boolean
    Returns whether or not there are any hops in this route.
    static Route
    Parses the given string as a list of space-separated hops.
    removeHop(int i)
    Removes the hop at a given index.
    setHop(int i, Hop hop)
    Sets the hop at a given index.
    Returns a string representation of this that can be debugged but not parsed.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Route

      public Route()

      Creates an empty route that contains no hops.

    • Route

      public Route(Route route)

      The copy constructor ignores integrity, it simply duplicates the list of hops in the other route. If that route is illegal, then so is this.

      Parameters:
      route - The route to copy.
    • Route

      public Route(List<Hop> hops)

      Constructs a route based on a list of hops.

      Parameters:
      hops - The hops to be contained in this.
  • Method Details

    • parse

      public static Route parse(String str)
      Parses the given string as a list of space-separated hops. The toString() method is compatible with this parser.
      Parameters:
      str - the string to parse
      Returns:
      a route that corresponds to the string
    • hasHops

      public boolean hasHops()

      Returns whether or not there are any hops in this route.

      Returns:
      True if there is at least one hop.
    • getNumHops

      public int getNumHops()

      Returns the number of hops that make up this route.

      Returns:
      The number of hops.
    • getHop

      public Hop getHop(int i)

      Returns the hop at the given index.

      Parameters:
      i - The index of the hop to return.
      Returns:
      The hop.
    • addHop

      public Route addHop(Hop hop)

      Adds a hop to the list of hops that make up this route.

      Parameters:
      hop - The hop to add.
      Returns:
      This, to allow chaining.
    • setHop

      public Route setHop(int i, Hop hop)

      Sets the hop at a given index.

      Parameters:
      i - The index at which to set the hop.
      hop - The hop to set.
      Returns:
      This, to allow chaining.
    • removeHop

      public Hop removeHop(int i)

      Removes the hop at a given index.

      Parameters:
      i - The index of the hop to remove.
      Returns:
      The hop removed.
    • clearHops

      public Route clearHops()

      Clears the list of hops that make up this route.

      Returns:
      This, to allow chaining.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toDebugString

      public String toDebugString()

      Returns a string representation of this that can be debugged but not parsed.

      Returns:
      The debug string.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object