Package foundation.omni
Class CurrencyID
java.lang.Object
foundation.omni.CurrencyID
- All Implemented Interfaces:
Comparable<CurrencyID>
Omni Protocol Currency Identifier
According to the OmniLayer Specification, Currency Identifier is an unsigned 32-bit value.
For storage efficiency reasons we are using a Java primitive (signed) int
for storing
the value. To implement this correctly we internally use Integer.toUnsignedLong(int)
when
converting to a (signed) long
. When converting from a valid currency id in a (signed) long
simply
using a cast operator produces the correct int
result.
All public interfaces use long
except ofUnsigned(int)
and unsignedIntValue()
which should be used with caution. Internal conversion to long
uses value()
.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CurrencyID
CurrencyID for AGRSstatic final long
Numeric ID value for AGRSstatic final CurrencyID
CurrencyID for AMPstatic final long
Numeric ID value for AMPstatic final CurrencyID
CurrencyID for BTCstatic final long
Numeric ID value for BTCstatic final CurrencyID
CurrencyID for EURTstatic final long
Numeric ID value for EURTstatic final CurrencyID
CurrencyID for MAIDstatic final long
Numeric ID value for MAIDstatic final long
Maximum allowed value for a "Real Ecosystem" (aka "Production") Omni CurrencyIDstatic final long
Maximum allowed value for a "Test Ecosystem" Omni CurrencyIDstatic final long
Maximum allowed value for an Omni CurrencyIDstatic final long
Minimum allowed value for an Omni CurrencyIDstatic final CurrencyID
CurrencyID for OMNIstatic final long
Numeric ID value for OMNIstatic final CurrencyID
CurrencyID for PDCstatic final long
Numeric ID value for PDCstatic final CurrencyID
CurrencyID for SAFEXstatic final long
Numeric ID value for SAFEXstatic final CurrencyID
CurrencyID for TOMNIstatic final long
Numeric ID value for TOMNIstatic final CurrencyID
CurrencyID for USDTstatic final long
Numeric ID value for USDT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
Getter-style access (for Groovy) toecosystem()
long
getValue()
Return the 32-bit unsigned value in a Javalong
.int
hashCode()
static boolean
isValid
(long value) is valid BTC or Real ecosystem or Test ecosystemstatic boolean
isValidReal
(long value) Is valid real ecosystem value Note BTC is not a valid real ecosystem valuestatic boolean
isValidTest
(long value) Is valid test ecosystem valuestatic CurrencyID
of
(long idValue) static CurrencyID
ofUnsigned
(int unsignedIntValue) toString()
int
Return the 32-bit unsigned value in a Javaint
.long
value()
static CurrencyID
-
Field Details
-
MIN_VALUE
public static final long MIN_VALUEMinimum allowed value for an Omni CurrencyID- See Also:
-
MAX_VALUE
public static final long MAX_VALUEMaximum allowed value for an Omni CurrencyID- See Also:
-
MAX_REAL_ECOSYSTEM_VALUE
public static final long MAX_REAL_ECOSYSTEM_VALUEMaximum allowed value for a "Real Ecosystem" (aka "Production") Omni CurrencyID- See Also:
-
MAX_TEST_ECOSYSTEM_VALUE
public static final long MAX_TEST_ECOSYSTEM_VALUEMaximum allowed value for a "Test Ecosystem" Omni CurrencyID- See Also:
-
BTC_VALUE
public static final long BTC_VALUENumeric ID value for BTC- See Also:
-
OMNI_VALUE
public static final long OMNI_VALUENumeric ID value for OMNI- See Also:
-
TOMNI_VALUE
public static final long TOMNI_VALUENumeric ID value for TOMNI- See Also:
-
MAID_VALUE
public static final long MAID_VALUENumeric ID value for MAID- See Also:
-
USDT_VALUE
public static final long USDT_VALUENumeric ID value for USDT- See Also:
-
AMP_VALUE
public static final long AMP_VALUENumeric ID value for AMP- See Also:
-
EURT_VALUE
public static final long EURT_VALUENumeric ID value for EURT- See Also:
-
SAFEX_VALUE
public static final long SAFEX_VALUENumeric ID value for SAFEX- See Also:
-
AGRS_VALUE
public static final long AGRS_VALUENumeric ID value for AGRS- See Also:
-
PDC_VALUE
public static final long PDC_VALUENumeric ID value for PDC- See Also:
-
BTC
CurrencyID for BTC -
OMNI
CurrencyID for OMNI -
TOMNI
CurrencyID for TOMNI -
MAID
CurrencyID for MAID -
USDT
CurrencyID for USDT -
AMP
CurrencyID for AMP -
EURT
CurrencyID for EURT -
SAFEX
CurrencyID for SAFEX -
AGRS
CurrencyID for AGRS -
PDC
CurrencyID for PDC
-
-
Constructor Details
-
CurrencyID
public CurrencyID(long value) Construct from a validlong
value.- Parameters:
value
- An valid currency id value (32-bit unsigned)- Throws:
IllegalArgumentException
- if value is out-out-range
-
-
Method Details
-
valueOf
- Parameters:
s
- A currency string for one of the well-known Omni currency tickers- Returns:
- the corresponding CurrencyID
-
of
- Parameters:
idValue
- A currency id (aka property id) numeric value- Returns:
- the corresponding CurrencyID
-
ofUnsigned
- Parameters:
unsignedIntValue
- A currency id (aka property id) numeric value- Returns:
- the corresponding CurrencyID
-
ecosystem
- Returns:
- ecosystem for this currency ID
-
getEcosystem
Getter-style access (for Groovy) toecosystem()
- Returns:
- ecosystem for this currency ID
-
isValid
public static boolean isValid(long value) is valid BTC or Real ecosystem or Test ecosystem- Parameters:
value
- currency id number- Returns:
- true if valid
-
isValidReal
public static boolean isValidReal(long value) Is valid real ecosystem value Note BTC is not a valid real ecosystem value- Parameters:
value
- currency id number- Returns:
- true if valid
-
isValidTest
public static boolean isValidTest(long value) Is valid test ecosystem value- Parameters:
value
- currency id number- Returns:
- true if valid
-
getValue
public long getValue()Return the 32-bit unsigned value in a Javalong
.Uses
Integer.toUnsignedLong(int)
to do a bitwise and operation to prevent sign extension.- Returns:
- CurrencyID value as a
long
-
value
public long value()- Returns:
- the number value
-
unsignedIntValue
public int unsignedIntValue()Return the 32-bit unsigned value in a Javaint
.Use this method with caution as Java treats
int
s as signed.- Returns:
- CurrencyID value as a
int
-
hashCode
public int hashCode() -
equals
-
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<CurrencyID>
-