public final class StandardId extends Object implements Comparable<StandardId>, org.joda.beans.ImmutableBean, Serializable
A standard identifier is used to uniquely identify domain objects. It is formed from two parts, the scheme and value.
The scheme defines a single way of identifying items, while the value is an identifier within that scheme. A value from one scheme may refer to a completely different real-world item than the same value from a different scheme.
Real-world examples of StandardId include instances of:
This class is immutable and thread-safe.
| Modifier and Type | Class and Description |
|---|---|
static class |
StandardId.Meta
The meta-bean for
StandardId. |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(StandardId other)
Compares the external identifiers, sorting alphabetically by scheme followed by value.
|
static String |
encodeScheme(String scheme)
Encode a string suitable for use as the scheme.
|
boolean |
equals(Object obj)
Checks if this identifier equals another, comparing the scheme and value.
|
String |
getScheme()
Gets the scheme that categorizes the identifier value.
|
String |
getValue()
Gets the value of the identifier within the scheme.
|
int |
hashCode()
Returns a suitable hash code, based on the scheme and value.
|
static StandardId.Meta |
meta()
The meta-bean for
StandardId. |
StandardId.Meta |
metaBean() |
static StandardId |
of(String scheme,
String value)
Obtains an instance from a scheme and value.
|
static StandardId |
parse(String str)
Parses an
StandardId from a formatted scheme and value. |
String |
toString()
Returns the identifier in a standard string format.
|
public static StandardId of(String scheme, String value)
The scheme must be non-empty and match the regular expression '[A-Za-z0-9:/+.=_%-]*'.
This permits letters, numbers, colon, forward-slash, plus, dot, equals, underscore and dash.
If necessary, the scheme can be encoded using encodeScheme(String).
The value must be non-empty and match the regular expression '[!-z][ -z]*'.
This includes all standard printable ASCII characters excluding curly brackets, pipe and tilde.
scheme - the scheme of the identifier, not emptyvalue - the value of the identifier, not emptypublic static StandardId parse(String str)
StandardId from a formatted scheme and value.
This parses the identifier from the form produced by toString()
which is '$scheme~$value'.
str - the identifier to parseIllegalArgumentException - if the identifier cannot be parsedpublic static String encodeScheme(String scheme)
This uses percent encoding, just like URI.
scheme - the scheme to encodepublic int compareTo(StandardId other)
compareTo in interface Comparable<StandardId>other - the other external identifierpublic boolean equals(Object obj)
public int hashCode()
public String toString()
The returned string is in the form '$scheme~$value'.
This is suitable for use with parse(String).
public static StandardId.Meta meta()
StandardId.public StandardId.Meta metaBean()
metaBean in interface org.joda.beans.Beanpublic String getScheme()
This provides the universe within which the identifier value has meaning.
public String getValue()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.