public final class ResourceIdentifier
extends java.lang.Object
#of(String)
to parse an existing identifier or the ability to generate new
identifiers by using provided context with method #of(String, String, String)
.
Resource identifier specification:
Resource Identifiers contain 4 components, prefixed by a format identifier ri and separated with periods:
ri.<service>.<instance>.<type>.<locator>
[a-z][a-z0-9\-]*
([a-z0-9][a-z0-9\-]*)?
[a-z][a-z0-9\-]*
[a-zA-Z0-9\-\._]+
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Compares the specified object with this identifier for equality.
|
java.lang.String |
getInstance()
Returns the instance component.
|
java.lang.String |
getLocator()
Returns the locator component.
|
java.lang.String |
getService()
Returns the service component.
|
java.lang.String |
getType()
Returns the type component.
|
int |
hashCode()
Returns the hash code value for identifier.
|
static boolean |
isValid(java.lang.String rid)
Checks if the input string is a valid resource identifier as defined in the specification.
|
static boolean |
isValidInstance(java.lang.String instance)
Checks if the input string is a valid instance as defined in the specification.
|
static boolean |
isValidLocator(java.lang.String locator)
Checks if the input string is a valid locator as defined in the specification.
|
static boolean |
isValidService(java.lang.String service)
Checks if the input string is a valid service as defined in the specification.
|
static boolean |
isValidType(java.lang.String type)
Checks if the input string is a valid type as defined in the specification.
|
static ResourceIdentifier |
of(java.lang.String rid)
Generates a new resource identifier object from the input string.
|
static ResourceIdentifier |
of(java.lang.String service,
java.lang.String instance,
java.lang.String type,
java.lang.String locator)
Generates a new resource identifier object from each of the 5 input components.
|
static ResourceIdentifier |
of(java.lang.String service,
java.lang.String instance,
java.lang.String type,
java.lang.String firstLocatorComponent,
java.lang.String... locatorComponents)
Generates a new resource identifier object from each of the input components.
|
java.lang.String |
toString()
Returns a string representation of this ResourceIdentifier.
|
static ResourceIdentifier |
valueOf(java.lang.String rid)
Same as
of(String) . |
public java.lang.String getService()
public java.lang.String getInstance()
public java.lang.String getType()
public java.lang.String getLocator()
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
Objects.hash(Object...)
method
over each of the 5 components.hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
true
if and only if the specified object is also a resource identifier and
contain exactly the same values for all 5 components.equals
in class java.lang.Object
obj
- the object to be compared for equality with this identifiertrue
if the specified object is equal to this identifier, false
otherwisepublic static boolean isValid(java.lang.String rid)
rid
- the input string to be checkedtrue
if and only if the input satisfy the resource identifier specification,
false
otherwise.public static boolean isValidService(java.lang.String service)
service
- the input string to be checkedtrue
if and only if the input satisfy the service specification,
false
otherwise.public static boolean isValidInstance(java.lang.String instance)
instance
- the input string to be checkedtrue
if and only if the input satisfy the instance specification,
false
otherwise.public static boolean isValidType(java.lang.String type)
type
- the input string to be checkedtrue
if and only if the input satisfy the type specification,
false
otherwise.public static boolean isValidLocator(java.lang.String locator)
locator
- the input string to be checkedtrue
if and only if the input satisfy the locator specification,
false
otherwise.public static ResourceIdentifier valueOf(java.lang.String rid)
of(String)
. Included to support JAX-RS
query and path parameterspublic static ResourceIdentifier of(java.lang.String rid)
rid
- the input string to be converted to a resource identifierjava.lang.IllegalArgumentException
- if the input string is not a valid resource identifierpublic static ResourceIdentifier of(java.lang.String service, java.lang.String instance, java.lang.String type, java.lang.String locator)
service
- input representing the service componentinstance
- input representing the instance componenttype
- input representing the type componentlocator
- input representing the locator componentjava.lang.IllegalArgumentException
- if any of the inputs do not satisfy the resource identifier specificationpublic static ResourceIdentifier of(java.lang.String service, java.lang.String instance, java.lang.String type, java.lang.String firstLocatorComponent, java.lang.String... locatorComponents)
service
- input representing the service componentinstance
- input representing the instance componenttype
- input representing the type componentfirstLocatorComponent
- the first part of the locator componentlocatorComponents
- the remaining locator componentsjava.lang.IllegalArgumentException
- if any of the inputs do not satisfy the resource identifier specification