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 CurrencyIDCurrencyID for AGRSstatic final longNumeric ID value for AGRSstatic final CurrencyIDCurrencyID for AMPstatic final longNumeric ID value for AMPstatic final CurrencyIDCurrencyID for BTCstatic final longNumeric ID value for BTCstatic final CurrencyIDCurrencyID for EURTstatic final longNumeric ID value for EURTstatic final CurrencyIDCurrencyID for MAIDstatic final longNumeric ID value for MAIDstatic final longMaximum allowed value for a "Real Ecosystem" (aka "Production") Omni CurrencyIDstatic final longMaximum allowed value for a "Test Ecosystem" Omni CurrencyIDstatic final longMaximum allowed value for an Omni CurrencyIDstatic final longMinimum allowed value for an Omni CurrencyIDstatic final CurrencyIDCurrencyID for OMNIstatic final longNumeric ID value for OMNIstatic final CurrencyIDCurrencyID for PDCstatic final longNumeric ID value for PDCstatic final CurrencyIDCurrencyID for SAFEXstatic final longNumeric ID value for SAFEXstatic final CurrencyIDCurrencyID for TOMNIstatic final longNumeric ID value for TOMNIstatic final CurrencyIDCurrencyID for USDTstatic final longNumeric ID value for USDT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbooleanGetter-style access (for Groovy) toecosystem()longgetValue()Return the 32-bit unsigned value in a Javalong.inthashCode()static booleanisValid(long value) is valid BTC or Real ecosystem or Test ecosystemstatic booleanisValidReal(long value) Is valid real ecosystem value Note BTC is not a valid real ecosystem valuestatic booleanisValidTest(long value) Is valid test ecosystem valuestatic CurrencyIDof(long idValue) static CurrencyIDofUnsigned(int unsignedIntValue) toString()intReturn the 32-bit unsigned value in a Javaint.longvalue()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 validlongvalue.- 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
ints as signed.- Returns:
- CurrencyID value as a
int
-
hashCode
public int hashCode() -
equals
-
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<CurrencyID>
-