Class StandardId
- java.lang.Object
-
- com.opengamma.strata.basics.StandardId
-
- All Implemented Interfaces:
Serializable,Comparable<StandardId>,org.joda.beans.Bean,org.joda.beans.ImmutableBean
public final class StandardId extends Object implements Comparable<StandardId>, org.joda.beans.ImmutableBean, Serializable
An immutable standard identifier for an item.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
StandardIdinclude instances of:- Cusip
- Isin
- Reuters RIC
- Bloomberg BUID
- Bloomberg Ticker
- Trading system OTC trade ID
This class is immutable and thread-safe.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStandardId.MetaThe meta-bean forStandardId.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(StandardId other)Compares the external identifiers, sorting alphabetically by scheme followed by value.static StringencodeScheme(String scheme)Encode a string suitable for use as the scheme.booleanequals(Object obj)Checks if this identifier equals another, comparing the scheme and value.StringgetScheme()Gets the scheme that categorizes the identifier value.StringgetValue()Gets the value of the identifier within the scheme.inthashCode()Returns a suitable hash code, based on the scheme and value.static StandardId.Metameta()The meta-bean forStandardId.StandardId.MetametaBean()static StandardIdof(String scheme, String value)Obtains an instance from a scheme and value.static StandardIdparse(String str)Parses anStandardIdfrom a formatted scheme and value.StringtoString()Returns the identifier in a standard string format.
-
-
-
Method Detail
-
of
public static StandardId of(String scheme, String value)
Obtains an instance from a scheme and 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 usingencodeScheme(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.- Parameters:
scheme- the scheme of the identifier, not emptyvalue- the value of the identifier, not empty- Returns:
- the identifier
-
parse
public static StandardId parse(String str)
Parses anStandardIdfrom a formatted scheme and value.This parses the identifier from the form produced by
toString()which is '$scheme~$value'.- Parameters:
str- the identifier to parse- Returns:
- the identifier
- Throws:
IllegalArgumentException- if the identifier cannot be parsed
-
encodeScheme
public static String encodeScheme(String scheme)
Encode a string suitable for use as the scheme.This uses percent encoding, just like URI.
- Parameters:
scheme- the scheme to encode- Returns:
- the encoded scheme
-
compareTo
public int compareTo(StandardId other)
Compares the external identifiers, sorting alphabetically by scheme followed by value.- Specified by:
compareToin interfaceComparable<StandardId>- Parameters:
other- the other external identifier- Returns:
- negative if this is less, zero if equal, positive if greater
-
equals
public boolean equals(Object obj)
Checks if this identifier equals another, comparing the scheme and value.
-
hashCode
public int hashCode()
Returns a suitable hash code, based on the scheme and value.
-
toString
public String toString()
Returns the identifier in a standard string format.The returned string is in the form '
$scheme~$value'. This is suitable for use withparse(String).
-
meta
public static StandardId.Meta meta()
The meta-bean forStandardId.- Returns:
- the meta-bean, not null
-
metaBean
public StandardId.Meta metaBean()
- Specified by:
metaBeanin interfaceorg.joda.beans.Bean
-
getScheme
public String getScheme()
Gets the scheme that categorizes the identifier value.This provides the universe within which the identifier value has meaning.
- Returns:
- the value of the property, not null
-
getValue
public String getValue()
Gets the value of the identifier within the scheme.- Returns:
- the value of the property, not null
-
-