Class RouteSpec


  • public class RouteSpec
    extends java.lang.Object
    Along with the RoutingSpec, RoutingTableSpec and HopSpec, 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 route.

    Author:
    Simon Thoresen Hult
    • Constructor Summary

      Constructors 
      Constructor Description
      RouteSpec​(RouteSpec obj)
      Implements the copy constructor.
      RouteSpec​(java.lang.String name)
      Creates a new named route specification.
      RouteSpec​(java.lang.String name, boolean verify)
      Creates a new named route specification.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      RouteSpec addHop​(java.lang.String hop)
      Adds the given hop name to this.
      RouteSpec addHops​(java.util.List<java.lang.String> hops)
      Adds the given hop names to this.
      RouteSpec clearHops()
      Clears the list of hops that make up this route.
      boolean equals​(java.lang.Object obj)  
      java.lang.String getHop​(int i)
      Returns the hop name at the given index.
      java.lang.String getName()
      Returns the protocol-unique name of this route.
      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.
      java.lang.String removeHop​(int i)
      Removes the hop name at the given index.
      RouteSpec setHop​(int i, java.lang.String hop)
      Sets the hop name for a 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.
      • Methods inherited from class java.lang.Object

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

      • RouteSpec

        public RouteSpec​(java.lang.String name)
        Creates a new named route specification.
        Parameters:
        name - A protocol-unique name for this route.
      • RouteSpec

        public RouteSpec​(java.lang.String name,
                         boolean verify)
        Creates a new named route specification.
        Parameters:
        name - A protocol-unique name for this route.
        verify - Whether or not this should be verified.
      • RouteSpec

        public RouteSpec​(RouteSpec 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 route.
        Returns:
        The name.
      • getHop

        public java.lang.String getHop​(int i)
        Returns the hop name at the given index.
        Parameters:
        i - The index of the hop to return.
        Returns:
        The hop at the given index.
      • 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.
      • addHop

        public RouteSpec addHop​(java.lang.String hop)
        Adds the given hop name to this.
        Parameters:
        hop - The hop to add.
        Returns:
        This, to allow chaining.
      • addHops

        public RouteSpec addHops​(java.util.List<java.lang.String> hops)
        Adds the given hop names to this.
        Parameters:
        hops - The hops to add.
        Returns:
        This, to allow chaining.
      • setHop

        public RouteSpec setHop​(int i,
                                java.lang.String hop)
        Sets the hop name for a given index.
        Parameters:
        i - The index of the hop to set.
        hop - The hop to set.
        Returns:
        This, to allow chaining.
      • removeHop

        public java.lang.String removeHop​(int i)
        Removes the hop name at the given index.
        Parameters:
        i - The index of the hop to remove.
        Returns:
        The removed hop.
      • clearHops

        public RouteSpec clearHops()
        Clears the list of hops that make up this route.
        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 class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object