Class Route
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
-
Method Summary
Modifier and TypeMethodDescriptionAdds 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
hashCode()
boolean
hasHops()
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.Sets the hop at a given index.Returns a string representation of this that can be debugged but not parsed.toString()
-
Constructor Details
-
Route
public Route()Creates an empty route that contains no hops.
-
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
Constructs a route based on a list of hops.
- Parameters:
hops
- The hops to be contained in this.
-
-
Method Details
-
parse
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
Returns the hop at the given index.
- Parameters:
i
- The index of the hop to return.- Returns:
- The hop.
-
addHop
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
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
Removes the hop at a given index.
- Parameters:
i
- The index of the hop to remove.- Returns:
- The hop removed.
-
clearHops
Clears the list of hops that make up this route.
- Returns:
- This, to allow chaining.
-
equals
-
toString
-
toDebugString
Returns a string representation of this that can be debugged but not parsed.
- Returns:
- The debug string.
-
hashCode
public int hashCode()
-