Class UriSpec

  • All Implemented Interfaces:
    java.lang.Iterable<UriSpec.Part>

    public class UriSpec
    extends java.lang.Object
    implements java.lang.Iterable<UriSpec.Part>

    An abstraction for specifying a URI for an instance allowing for variable substitutions.

    A Uri spec is a string with optional replacement fields. A replacement field begins with an open brace and ends with a close brace. The value between the braces is the name of the field. e.g. "{scheme}://foo.com:{port}" has two replacement fields named "scheme" and "port". Several pre-defined fields are listed as constants in this class (e.g. FIELD_SCHEME).

    • Constructor Detail

      • UriSpec

        public UriSpec()
      • UriSpec

        public UriSpec​(java.lang.String rawSpec)
        Parameters:
        rawSpec - the spec to parse
    • Method Detail

      • build

        public java.lang.String build()
        Build into a UriSpec string
        Returns:
        UriSpec string
      • build

        public java.lang.String build​(ServiceInstance<?> serviceInstance)
        Build into a UriSpec string
        Parameters:
        serviceInstance - instance to use for pre-defined replacement fields
        Returns:
        UriSpec string
      • build

        public java.lang.String build​(java.util.Map<java.lang.String,​java.lang.Object> variables)
        Build into a UriSpec string
        Parameters:
        variables - a mapping of field replacement names to values. Note: any fields listed in this map override pre-defined fields
        Returns:
        UriSpec string
      • build

        public java.lang.String build​(ServiceInstance<?> serviceInstance,
                                      java.util.Map<java.lang.String,​java.lang.Object> variables)
        Build into a UriSpec string
        Parameters:
        serviceInstance - instance to use for pre-defined replacement fields
        variables - a mapping of field replacement names to values. Note: any fields listed in this map override pre-defined fields
        Returns:
        UriSpec string
      • iterator

        public java.util.Iterator<UriSpec.Part> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<UriSpec.Part>
      • getParts

        public java.util.List<UriSpec.Part> getParts()
        Returns:
        the parts
      • add

        public void add​(UriSpec.Part part)
        Add a part to the end of the list
        Parameters:
        part - part to add
      • remove

        public void remove​(UriSpec.Part part)
        Remove the given part
        Parameters:
        part - the part
      • equals

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

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