Package org.apache.curator.x.discovery
Class UriSpec
java.lang.Object
org.apache.curator.x.discovery.UriSpec
- All Implemented Interfaces:
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
).
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
If aServiceInstance
is passed when building, the replacement isServiceInstance.getAddress()
static final String
Always replaced with '}' - i.e.static final String
If aServiceInstance
is passed when building, the replacement isServiceInstance.getId()
static final String
If aServiceInstance
is passed when building, the replacement isServiceInstance.getName()
static final String
Always replaced with '{' - i.e.static final String
If aServiceInstance
is passed when building, the replacement isServiceInstance.getPort()
static final String
If aServiceInstance
is passed when building, the replacement isServiceInstance.getRegistrationTimeUTC()
static final String
This defaults to "http".static final String
If aServiceInstance
is passed when building, the replacement isServiceInstance.getServiceType()
static final String
If aServiceInstance
is passed when building, the replacement isServiceInstance.getSslPort()
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(UriSpec.Part part) Add a part to the end of the listbuild()
Build into a UriSpec stringBuild into a UriSpec stringbuild
(ServiceInstance<?> serviceInstance) Build into a UriSpec stringbuild
(ServiceInstance<?> serviceInstance, Map<String, Object> variables) Build into a UriSpec stringboolean
getParts()
int
hashCode()
iterator()
void
remove
(UriSpec.Part part) Remove the given partMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
FIELD_SCHEME
This defaults to "http". If aServiceInstance
is passed when building and an sslPort is specified in the instance, the replacement is "https".- See Also:
-
FIELD_NAME
If aServiceInstance
is passed when building, the replacement isServiceInstance.getName()
- See Also:
-
FIELD_ID
If aServiceInstance
is passed when building, the replacement isServiceInstance.getId()
- See Also:
-
FIELD_ADDRESS
If aServiceInstance
is passed when building, the replacement isServiceInstance.getAddress()
- See Also:
-
FIELD_PORT
If aServiceInstance
is passed when building, the replacement isServiceInstance.getPort()
- See Also:
-
FIELD_SSL_PORT
If aServiceInstance
is passed when building, the replacement isServiceInstance.getSslPort()
- See Also:
-
FIELD_REGISTRATION_TIME_UTC
If aServiceInstance
is passed when building, the replacement isServiceInstance.getRegistrationTimeUTC()
- See Also:
-
FIELD_SERVICE_TYPE
If aServiceInstance
is passed when building, the replacement isServiceInstance.getServiceType()
- See Also:
-
FIELD_OPEN_BRACE
Always replaced with '{' - i.e. this is how to insert a literal '{'- See Also:
-
FIELD_CLOSE_BRACE
Always replaced with '}' - i.e. this is how to insert a literal '}'- See Also:
-
-
Constructor Details
-
UriSpec
public UriSpec() -
UriSpec
- Parameters:
rawSpec
- the spec to parse
-
-
Method Details
-
build
Build into a UriSpec string- Returns:
- UriSpec string
-
build
Build into a UriSpec string- Parameters:
serviceInstance
- instance to use for pre-defined replacement fields- Returns:
- UriSpec string
-
build
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
Build into a UriSpec string- Parameters:
serviceInstance
- instance to use for pre-defined replacement fieldsvariables
- a mapping of field replacement names to values. Note: any fields listed in this map override pre-defined fields- Returns:
- UriSpec string
-
iterator
- Specified by:
iterator
in interfaceIterable<UriSpec.Part>
-
getParts
- Returns:
- the parts
-
add
Add a part to the end of the list- Parameters:
part
- part to add
-
remove
Remove the given part- Parameters:
part
- the part
-
equals
-
hashCode
public int hashCode()
-