Class Route
- java.lang.Object
-
- com.yahoo.messagebus.routing.Route
-
public class Route extends java.lang.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 invokedRoutingPolicy
, 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 Route()
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(java.util.List<Hop> hops)
Constructs a route based on a list of hops.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Route
addHop(Hop hop)
Adds a hop to the list of hops that make up this route.Route
clearHops()
Clears the list of hops that make up this route.boolean
equals(java.lang.Object obj)
Hop
getHop(int i)
Returns the hop at the given index.int
getNumHops()
Returns the number of hops that make up this route.int
hashCode()
boolean
hasHops()
Returns whether or not there are any hops in this route.static Route
parse(java.lang.String str)
Parses the given string as a list of space-separated hops.Hop
removeHop(int i)
Removes the hop at a given index.Route
setHop(int i, Hop hop)
Sets the hop at a given index.java.lang.String
toDebugString()
Returns a string representation of this that can be debugged but not parsed.java.lang.String
toString()
-
-
-
Constructor Detail
-
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(java.util.List<Hop> hops)
Constructs a route based on a list of hops.
- Parameters:
hops
- The hops to be contained in this.
-
-
Method Detail
-
parse
public static Route parse(java.lang.String str)
Parses the given string as a list of space-separated hops. ThetoString()
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(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toDebugString
public java.lang.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 classjava.lang.Object
-
-