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
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringIf aServiceInstanceis passed when building, the replacement isServiceInstance.getAddress()static final StringAlways replaced with '}' - i.e.static final StringIf aServiceInstanceis passed when building, the replacement isServiceInstance.getId()static final StringIf aServiceInstanceis passed when building, the replacement isServiceInstance.getName()static final StringAlways replaced with '{' - i.e.static final StringIf aServiceInstanceis passed when building, the replacement isServiceInstance.getPort()static final StringIf aServiceInstanceis passed when building, the replacement isServiceInstance.getRegistrationTimeUTC()static final StringThis defaults to "http".static final StringIf aServiceInstanceis passed when building, the replacement isServiceInstance.getServiceType()static final StringIf aServiceInstanceis passed when building, the replacement isServiceInstance.getSslPort() -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(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 stringbooleangetParts()inthashCode()iterator()voidremove(UriSpec.Part part) Remove the given partMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
FIELD_SCHEME
This defaults to "http". If aServiceInstanceis passed when building and an sslPort is specified in the instance, the replacement is "https".- See Also:
-
FIELD_NAME
If aServiceInstanceis passed when building, the replacement isServiceInstance.getName()- See Also:
-
FIELD_ID
If aServiceInstanceis passed when building, the replacement isServiceInstance.getId()- See Also:
-
FIELD_ADDRESS
If aServiceInstanceis passed when building, the replacement isServiceInstance.getAddress()- See Also:
-
FIELD_PORT
If aServiceInstanceis passed when building, the replacement isServiceInstance.getPort()- See Also:
-
FIELD_SSL_PORT
If aServiceInstanceis passed when building, the replacement isServiceInstance.getSslPort()- See Also:
-
FIELD_REGISTRATION_TIME_UTC
If aServiceInstanceis passed when building, the replacement isServiceInstance.getRegistrationTimeUTC()- See Also:
-
FIELD_SERVICE_TYPE
If aServiceInstanceis 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:
iteratorin 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()
-