Class CurrencyID

java.lang.Object
foundation.omni.CurrencyID
All Implemented Interfaces:
Comparable<CurrencyID>

public final class CurrencyID extends Object implements 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 Details

    • MIN_VALUE

      public static final long MIN_VALUE
      Minimum allowed value for an Omni CurrencyID
      See Also:
    • MAX_VALUE

      public static final long MAX_VALUE
      Maximum allowed value for an Omni CurrencyID
      See Also:
    • MAX_REAL_ECOSYSTEM_VALUE

      public static final long MAX_REAL_ECOSYSTEM_VALUE
      Maximum allowed value for a "Real Ecosystem" (aka "Production") Omni CurrencyID
      See Also:
    • MAX_TEST_ECOSYSTEM_VALUE

      public static final long MAX_TEST_ECOSYSTEM_VALUE
      Maximum allowed value for a "Test Ecosystem" Omni CurrencyID
      See Also:
    • BTC_VALUE

      public static final long BTC_VALUE
      Numeric ID value for BTC
      See Also:
    • OMNI_VALUE

      public static final long OMNI_VALUE
      Numeric ID value for OMNI
      See Also:
    • TOMNI_VALUE

      public static final long TOMNI_VALUE
      Numeric ID value for TOMNI
      See Also:
    • MAID_VALUE

      public static final long MAID_VALUE
      Numeric ID value for MAID
      See Also:
    • USDT_VALUE

      public static final long USDT_VALUE
      Numeric ID value for USDT
      See Also:
    • AMP_VALUE

      public static final long AMP_VALUE
      Numeric ID value for AMP
      See Also:
    • EURT_VALUE

      public static final long EURT_VALUE
      Numeric ID value for EURT
      See Also:
    • SAFEX_VALUE

      public static final long SAFEX_VALUE
      Numeric ID value for SAFEX
      See Also:
    • AGRS_VALUE

      public static final long AGRS_VALUE
      Numeric ID value for AGRS
      See Also:
    • PDC_VALUE

      public static final long PDC_VALUE
      Numeric ID value for PDC
      See Also:
    • BTC

      public static final CurrencyID BTC
      CurrencyID for BTC
    • OMNI

      public static final CurrencyID OMNI
      CurrencyID for OMNI
    • TOMNI

      public static final CurrencyID TOMNI
      CurrencyID for TOMNI
    • MAID

      public static final CurrencyID MAID
      CurrencyID for MAID
    • USDT

      public static final CurrencyID USDT
      CurrencyID for USDT
    • AMP

      public static final CurrencyID AMP
      CurrencyID for AMP
    • EURT

      public static final CurrencyID EURT
      CurrencyID for EURT
    • SAFEX

      public static final CurrencyID SAFEX
      CurrencyID for SAFEX
    • AGRS

      public static final CurrencyID AGRS
      CurrencyID for AGRS
    • PDC

      public static final CurrencyID PDC
      CurrencyID for PDC
  • Constructor Details

    • CurrencyID

      public CurrencyID(long value)
      Construct from a valid long value.
      Parameters:
      value - An valid currency id value (32-bit unsigned)
      Throws:
      IllegalArgumentException - if value is out-out-range
  • Method Details

    • valueOf

      public static CurrencyID valueOf(String s)
      Parameters:
      s - A currency string for one of the well-known Omni currency tickers
      Returns:
      the corresponding CurrencyID
    • of

      public static CurrencyID of(long idValue)
      Parameters:
      idValue - A currency id (aka property id) numeric value
      Returns:
      the corresponding CurrencyID
    • ofUnsigned

      public static CurrencyID ofUnsigned(int unsignedIntValue)
      Parameters:
      unsignedIntValue - A currency id (aka property id) numeric value
      Returns:
      the corresponding CurrencyID
    • ecosystem

      public Ecosystem ecosystem()
      Returns:
      ecosystem for this currency ID
    • getEcosystem

      public Ecosystem getEcosystem()
      Getter-style access (for Groovy) to ecosystem()
      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 Java long.

      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 Java int.

      Use this method with caution as Java treats ints as signed.

      Returns:
      CurrencyID value as a int
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(CurrencyID o)
      Specified by:
      compareTo in interface Comparable<CurrencyID>