Package com.yahoo.messagebus.routing
Class HopSpec
- java.lang.Object
-
- com.yahoo.messagebus.routing.HopSpec
-
public class HopSpec extends java.lang.Object
Along with theRoutingSpec
,RoutingTableSpec
andRouteSpec
, this holds the routing specifications for all protocols. The only way a client can configure or alter the settings of a message bus instance is through these classes.This class contains the spec for a single hop.
- Author:
- Simon Thoresen Hult
-
-
Constructor Summary
Constructors Constructor Description HopSpec(HopSpec obj)
Implements the copy constructor.HopSpec(java.lang.String name, java.lang.String selector)
Creates a new named hop specification.HopSpec(java.lang.String name, java.lang.String selector, boolean verify)
Creates a new named hop specification.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HopSpec
addRecipient(java.lang.String recipient)
Adds the given recipient to this.HopSpec
addRecipients(java.util.List<java.lang.String> recipients)
Adds the given recipients to this.HopSpec
clearRecipients()
Clears the list of recipients that the selector may choose from.boolean
equals(java.lang.Object obj)
boolean
getIgnoreResult()
Returns whether or not to ignore the result when routing through this hop.java.lang.String
getName()
Returns the protocol-unique name of this hop.int
getNumRecipients()
Returns the number of recipients that the selector can choose from.java.lang.String
getRecipient(int i)
Returns the recipients at the given index.java.lang.String
getSelector()
Returns the string selector that resolves the recipients of this hop.int
hashCode()
boolean
hasRecipients()
Returns whether or not there are any recipients that the selector can choose from.java.lang.String
removeRecipient(int i)
Removes the recipient at the given index.HopSpec
setIgnoreResult(boolean ignoreResult)
Sets whether or not to ignore the result when routing through this hop.HopSpec
setRecipient(int i, java.lang.String recipient)
Sets the recipient at the given index.void
toConfig(java.lang.StringBuilder cfg, java.lang.String prefix)
Appends the content of this to the given config string builder.java.lang.String
toString()
boolean
verify(ApplicationSpec app, RoutingTableSpec table, java.util.List<java.lang.String> errors)
Verifies the content of this against the given application.
-
-
-
Constructor Detail
-
HopSpec
public HopSpec(java.lang.String name, java.lang.String selector)
Creates a new named hop specification.- Parameters:
name
- A protocol-unique name for this hop.selector
- A string that represents the selector for this hop.
-
HopSpec
public HopSpec(java.lang.String name, java.lang.String selector, boolean verify)
Creates a new named hop specification.- Parameters:
name
- A protocol-unique name for this hop.selector
- A string that represents the selector for this hop.verify
- Whether or not this should be verified.
-
HopSpec
public HopSpec(HopSpec obj)
Implements the copy constructor.- Parameters:
obj
- The object to copy.
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the protocol-unique name of this hop.- Returns:
- The name.
-
getSelector
public java.lang.String getSelector()
Returns the string selector that resolves the recipients of this hop.- Returns:
- The selector.
-
hasRecipients
public boolean hasRecipients()
Returns whether or not there are any recipients that the selector can choose from.- Returns:
- True if there is at least one recipient.
-
getNumRecipients
public int getNumRecipients()
Returns the number of recipients that the selector can choose from.- Returns:
- The number of recipients.
-
getRecipient
public java.lang.String getRecipient(int i)
Returns the recipients at the given index.- Parameters:
i
- The index of the recipient to return.- Returns:
- The recipient at the given index.
-
addRecipient
public HopSpec addRecipient(java.lang.String recipient)
Adds the given recipient to this.- Parameters:
recipient
- The recipient to add.- Returns:
- This, to allow chaining.
-
addRecipients
public HopSpec addRecipients(java.util.List<java.lang.String> recipients)
Adds the given recipients to this.- Parameters:
recipients
- The recipients to add.- Returns:
- This, to allow chaining.
-
setRecipient
public HopSpec setRecipient(int i, java.lang.String recipient)
Sets the recipient at the given index.- Parameters:
i
- The index at which to set the recipient.recipient
- The recipient to set.- Returns:
- This, to allow chaining.
-
removeRecipient
public java.lang.String removeRecipient(int i)
Removes the recipient at the given index.- Parameters:
i
- The index of the recipient to remove.- Returns:
- The removed recipient.
-
clearRecipients
public HopSpec clearRecipients()
Clears the list of recipients that the selector may choose from.- Returns:
- This, to allow chaining.
-
getIgnoreResult
public boolean getIgnoreResult()
Returns whether or not to ignore the result when routing through this hop.- Returns:
- True to ignore the result.
-
setIgnoreResult
public HopSpec setIgnoreResult(boolean ignoreResult)
Sets whether or not to ignore the result when routing through this hop.- Parameters:
ignoreResult
- Whether or not to ignore the result.- Returns:
- This, to allow chaining.
-
verify
public boolean verify(ApplicationSpec app, RoutingTableSpec table, java.util.List<java.lang.String> errors)
Verifies the content of this against the given application.- Parameters:
app
- The application to verify against.table
- The routing table to verify against.errors
- The list of errors found.- Returns:
- True if no errors where found.
-
toConfig
public void toConfig(java.lang.StringBuilder cfg, java.lang.String prefix)
Appends the content of this to the given config string builder.- Parameters:
cfg
- The config to add to.prefix
- The prefix to use for each add.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-